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
end
def online?
cached_contacted_at && cached_contacted_at > self.class.contact_time_deadline
contacted_at && cached_contacted_at > self.class.contact_time_deadline
end
def status
......
......@@ -128,6 +128,7 @@ describe Ci::Runner do
context 'with cache value' do
context 'contacted long time ago time' do
before do
runner.contacted_at = 1.year.ago
stub_redis_runner_contacted_at(1.year.ago.to_s)
end
......@@ -136,6 +137,7 @@ describe Ci::Runner do
context 'contacted 1s ago' do
before do
runner.contacted_at = 50.minutes.ago
stub_redis_runner_contacted_at(1.second.ago.to_s)
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