Commit 3be6f68a authored by Matija Čupić's avatar Matija Čupić

Make Ci::Runner#online? slightly more performant

This is a small refactor to avoid querying Redis when we know there's
nothing in it.
parent b88103e4
...@@ -97,7 +97,7 @@ module Ci ...@@ -97,7 +97,7 @@ module Ci
end end
def online? def online?
cached_contacted_at && cached_contacted_at > self.class.contact_time_deadline contacted_at && cached_contacted_at > self.class.contact_time_deadline
end end
def status def status
......
...@@ -128,6 +128,7 @@ describe Ci::Runner do ...@@ -128,6 +128,7 @@ describe Ci::Runner do
context 'with cache value' do context 'with cache value' do
context 'contacted long time ago time' do context 'contacted long time ago time' do
before do before do
runner.contacted_at = 1.year.ago
stub_redis_runner_contacted_at(1.year.ago.to_s) stub_redis_runner_contacted_at(1.year.ago.to_s)
end end
...@@ -136,6 +137,7 @@ describe Ci::Runner do ...@@ -136,6 +137,7 @@ describe Ci::Runner do
context 'contacted 1s ago' do context 'contacted 1s ago' do
before do before do
runner.contacted_at = 50.minutes.ago
stub_redis_runner_contacted_at(1.second.ago.to_s) stub_redis_runner_contacted_at(1.second.ago.to_s)
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