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 0f22680

Browse files
author
v.promzelev
committed
move predicate to method
1 parent f7450e2 commit 0f22680

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

‎lib/activerecord/overflow_signalizer.rb‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,18 @@ def analyse!
2525
model = models.first
2626
pk = model.columns.select { |c| c.name == model.primary_key }.first
2727
next if model.last.nil?
28-
if (max_value(pk.sql_type) - model.last.id) / avg(model) <= @days_count
28+
if overflow_soon?(pk,model)
2929
signalize(table, model.last.public_send(pk.name), max_value(pk.sql_type))
3030
end
3131
end
3232
end
3333

3434
private
3535

36+
def overflow_soon?(pk, model)
37+
(max_value(pk.sql_type) - model.last.id) / avg(model) <= @days_count
38+
end
39+
3640
def avg(model)
3741
yesterday = Time.now
3842
week_records = (1..7).map do |t|

0 commit comments

Comments
(0)

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