diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2021-11-26 01:12:39 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-26 01:12:39 +0100 |
commit | 12b3ff6c6d70df1ce34f4b103b519250c9e2d2c8 (patch) | |
tree | f64f6d487b6cb17342e9096296deb69d3adf4e98 | |
parent | b1fd6d44901a13450d22884b02eb6e9ae4fc1248 (diff) |
Fix error on trending hashtags/links pages in admin UI due to missing constant (#17044)
-rw-r--r-- | app/models/preview_card.rb | 4 | ||||
-rw-r--r-- | app/models/tag.rb | 4 | ||||
-rw-r--r-- | app/views/admin/trends/links/_preview_card.html.haml | 2 | ||||
-rw-r--r-- | app/views/admin/trends/tags/_tag.html.haml | 2 |
4 files changed, 10 insertions, 2 deletions
diff --git a/app/models/preview_card.rb b/app/models/preview_card.rb index f2ab8ecab..0f9e23fa1 100644 --- a/app/models/preview_card.rb +++ b/app/models/preview_card.rb @@ -84,6 +84,10 @@ class PreviewCard < ApplicationRecord attributes['trendable'].nil? && (provider.nil? || provider.requires_review_notification?) end + def decaying? + max_score_at && max_score_at >= Trends.links.options[:max_score_cooldown].ago && max_score_at < 1.day.ago + end + attr_writer :provider def local? diff --git a/app/models/tag.rb b/app/models/tag.rb index f35d92b5d..a64042614 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -80,6 +80,10 @@ class Tag < ApplicationRecord requires_review? && !requested_review? end + def decaying? + max_score_at && max_score_at >= Trends.tags.options[:max_score_cooldown].ago && max_score_at < 1.day.ago + end + def history @history ||= Trends::History.new('tags', id) end diff --git a/app/views/admin/trends/links/_preview_card.html.haml b/app/views/admin/trends/links/_preview_card.html.haml index dfed13b68..b88c1be2f 100644 --- a/app/views/admin/trends/links/_preview_card.html.haml +++ b/app/views/admin/trends/links/_preview_card.html.haml @@ -22,7 +22,7 @@ • %abbr{ title: t('admin.trends.tags.current_score', score: Trends.links.score(preview_card.id)) }= t('admin.trends.tags.trending_rank', rank: rank + 1) - - if preview_card.max_score_at && preview_card.max_score_at >= Trends::Links::MAX_SCORE_COOLDOWN.ago && preview_card.max_score_at < 1.day.ago + - if preview_card.decaying? • = t('admin.trends.tags.peaked_on_and_decaying', date: l(preview_card.max_score_at.to_date, format: :short)) - elsif preview_card.provider&.requires_review? diff --git a/app/views/admin/trends/tags/_tag.html.haml b/app/views/admin/trends/tags/_tag.html.haml index c4af77b00..7bb99b158 100644 --- a/app/views/admin/trends/tags/_tag.html.haml +++ b/app/views/admin/trends/tags/_tag.html.haml @@ -16,7 +16,7 @@ • %abbr{ title: t('admin.trends.tags.current_score', score: Trends.tags.score(tag.id)) }= t('admin.trends.tags.trending_rank', rank: rank + 1) - - if tag.max_score_at && tag.max_score_at >= Trends::Tags::MAX_SCORE_COOLDOWN.ago && tag.max_score_at < 1.day.ago + - if tag.decaying? • = t('admin.trends.tags.peaked_on_and_decaying', date: l(tag.max_score_at.to_date, format: :short)) - elsif tag.requires_review? |