Skip to content

Commit

Permalink
fix: do not report a bucket we've already reported && do not report a…
Browse files Browse the repository at this point in the history
… bucket that has not completed.
  • Loading branch information
jim80net committed May 5, 2020
1 parent 7ab2318 commit 9dbd02e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
4 changes: 2 additions & 2 deletions lib/slowlog_check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ def slowlog_microseconds(slowlog)
end

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

def _95percentile(sorted_values)
Expand Down
17 changes: 7 additions & 10 deletions spec/slowlog_check_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -216,16 +216,13 @@ def redis_slowlog(index, time, microseconds, command='eval')
end

describe '#reporting_interval' do
subject { slowlog_check.reporting_interval.map {|x| x[0]} }
it 'generates an array at minute intervals' do
minute_precision_time = slowlog_check.minute_precision(Time.now)

expect(subject).to contain_exactly(
minute_precision_time,
minute_precision_time - 60,
minute_precision_time - 120,
minute_precision_time - 180
)
subject { slowlog_check.reporting_interval }
focus 'generates an array at minute intervals' do
expect(subject).to eq(
Time.utc(2020,4,20,4,19).localtime => {},
Time.utc(2020,4,20,4,18).localtime => {},
Time.utc(2020,4,20,4,17).localtime => {},
)
end
end

Expand Down

0 comments on commit 9dbd02e

Please sign in to comment.