Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Oct 28, 2020. It is now read-only.

Commit c1693ca

Browse files
author
v.promzelev
committed
use default value for avg if model doesnt have created_at
1 parent 77c341f commit c1693ca

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

‎lib/activerecord/overflow_signalizer.rb‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ def initialize(type = nil)
1212
end
1313

1414
DAY = 24 * 60 * 60
15+
DEFAULT_AVG = 100_000
1516

1617
MAX_VALUE = {
1718
'integer' => 2_147_483_647,
@@ -40,7 +41,11 @@ def analyse!
4041
private
4142

4243
def overflow_soon?(max, model)
43-
(max - model.last.id) / avg(model) <= @days_count
44+
if model.columns.select { |c| c.name == 'created_at' }.empty?
45+
(max - model.last.id) / DEFAULT_AVG <= @days_count
46+
else
47+
(max - model.last.id) / avg(model) <= @days_count
48+
end
4449
end
4550

4651
def avg(model)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /