lib/legion/extensions/health/runners/health.rb in lex-health-0.1.2 vs lib/legion/extensions/health/runners/health.rb in lex-health-0.1.3
- old
+ new
@@ -2,11 +2,11 @@
module Runners
module Health
include Legion::Extensions::Helpers::Lex
def update(hostname:, **opts)
- item = Legion::Data::Model::Node.where(name: hostname).first
+ item = Legion::Data::Model::Node[name: hostname]
return { success: insert(hostname: hostname, **opts), hostname: hostname, **opts } if item.nil?
if opts.key?(:timestamp) && !item.values[:updated].nil? && item.values[:updated] > Time.parse(opts[:timestamp])
return { success: false,
@@ -14,10 +14,14 @@
hostname: hostname,
db_updated: item.values[:updated],
**opts }
end
- { success: item.update(active: 1, status: opts[:status], name: hostname), hostname: hostname, **opts }
+ {
+ success: item.update(active: 1, status: opts[:status], name: hostname, updated: Sequel::CURRENT_TIMESTAMP),
+ hostname: hostname,
+ **opts
+ }
end
def insert(hostname:, status: 'unknown', **opts)
insert = { active: 1, status: status, name: hostname }
insert[:datacenter_id] = opts[:datacenter_id] if opts.key? :datacenter_id