Commit 94740c66 authored by nazarf's avatar nazarf

fix check miners

parent 17e00c6b
...@@ -4,7 +4,7 @@ namespace :miners do ...@@ -4,7 +4,7 @@ namespace :miners do
response = HTTParty.get(url) response = HTTParty.get(url)
response_json = JSON.parse(response.body) response_json = JSON.parse(response.body)
time = DateTime.new time = DateTime.now
miners = Miner.all miners = Miner.all
if response_json == [] if response_json == []
...@@ -17,6 +17,7 @@ namespace :miners do ...@@ -17,6 +17,7 @@ namespace :miners do
is_work = false is_work = false
hr_stats = 0 hr_stats = 0
check_activity_time = (DateTime.now - 5.minutes) check_activity_time = (DateTime.now - 5.minutes)
last_activity_time = miner.last_activity || check_activity_time
response_json.each do |item| response_json.each do |item|
if item['work_id'] == miner.name if item['work_id'] == miner.name
...@@ -29,7 +30,7 @@ namespace :miners do ...@@ -29,7 +30,7 @@ namespace :miners do
if is_work if is_work
miner.update(status: 'work', hash_rate: hr_stats) miner.update(status: 'work', hash_rate: hr_stats)
else else
if miner.last_activity < check_activity_time if last_activity_time <= check_activity_time
miner.update(status: 'miss', last_activity: time, hash_rate: hr_stats) miner.update(status: 'miss', last_activity: time, hash_rate: hr_stats)
end end
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment