Safety check before using row values.

FossilOrigin-Name: 762164d99717433a03474f5e927c58540f5a2863404e3c69f8f83fd04cad624f
This commit is contained in:
mahlon@laika.com 2014-10-28 18:58:07 +00:00
parent 7c2954b0ad
commit 649332a422
2 changed files with 8 additions and 9 deletions

View file

@ -180,8 +180,12 @@ class Symphony::Metronome::ScheduledEvent
# #
if self.event.recurring if self.event.recurring
now = Time.now now = Time.now
last = self.ds.first[ :lastrun ] row = self.ds.first
if row
last = row[ :lastrun ]
return false if last && now - last < self.event.interval return false if last && now - last < self.event.interval
end
# Mark the time this recurring event was fired. # Mark the time this recurring event was fired.
self.ds.update( :lastrun => Time.now ) self.ds.update( :lastrun => Time.now )

View file

@ -9,11 +9,6 @@ describe Symphony::Metronome::Scheduler do
described_class.configure described_class.configure
end end
it 'spins up an AMQP listener by default' do # needs tests
# described_class.run {}
# expect( described_class.listen ).to eq( :sd )
end
end end