Skip to content

Commit 9dbd02e

Browse files
committed
fix: do not report a bucket we've already reported && do not report a bucket that has not completed.
1 parent 7ab2318 commit 9dbd02e

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

lib/slowlog_check.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ def slowlog_microseconds(slowlog)
7878
end
7979

8080
def reporting_interval
81-
now_i = Time.now.to_i
81+
now_i = minute_precision(Time.now).to_i - 60
8282
start_time_i = last_time_submitted.to_i + 60
8383
times = (start_time_i..now_i).step(60).to_a
84-
Hash[times.collect {|time| [Time.at(time), nil]}]
84+
Hash[times.collect {|time| [Time.at(time), {}]}]
8585
end
8686

8787
def _95percentile(sorted_values)

spec/slowlog_check_spec.rb

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -216,16 +216,13 @@ def redis_slowlog(index, time, microseconds, command='eval')
216216
end
217217

218218
describe '#reporting_interval' do
219-
subject { slowlog_check.reporting_interval.map {|x| x[0]} }
220-
it 'generates an array at minute intervals' do
221-
minute_precision_time = slowlog_check.minute_precision(Time.now)
222-
223-
expect(subject).to contain_exactly(
224-
minute_precision_time,
225-
minute_precision_time - 60,
226-
minute_precision_time - 120,
227-
minute_precision_time - 180
228-
)
219+
subject { slowlog_check.reporting_interval }
220+
focus 'generates an array at minute intervals' do
221+
expect(subject).to eq(
222+
Time.utc(2020,4,20,4,19).localtime => {},
223+
Time.utc(2020,4,20,4,18).localtime => {},
224+
Time.utc(2020,4,20,4,17).localtime => {},
225+
)
229226
end
230227
end
231228

0 commit comments

Comments
 (0)