Skip to content

Commit f9e4cc0

Browse files
committed
Sleep 60 seconds and retry if raise Statistics::Client::APIRateLimitError
1 parent c82e145 commit f9e4cc0

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/tasks/statistics.rake

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,15 @@ namespace :statistics do
4242
raise StopIteration if nm > to
4343
list << nm
4444
}.each { |date|
45-
Statistics::Aggregation.run(date: date)
45+
begin
46+
puts "Aggregate for #{date.strftime('%Y/%m')}"
47+
Statistics::Aggregation.run(date: date)
48+
rescue Statistics::Client::APIRateLimitError
49+
puts 'API rate limit exceeded.'
50+
puts "This task will retry in 60 seconds from now(#{Time.zone.now})."
51+
sleep 60
52+
retry
53+
end
4654
}
4755
end
4856

0 commit comments

Comments
 (0)