about summary refs log tree commit diff
path: root/app/models/trends/statuses.rb
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2022-04-08 19:35:31 +0200
committerGitHub <noreply@github.com>2022-04-08 19:35:31 +0200
commit68273a7c6d6c630b6c88764579580682e12eebce (patch)
tree5d4c17b01c5088506c074f09fab6ed51b38a3703 /app/models/trends/statuses.rb
parenta39bf04fe6b6a98547737cc15f42727428376e67 (diff)
Fix dangling language-specific trends (#17997)
- Change score half-life for trending statuses from 2 to 6 hours
- Change score threshold for trimming old items from 1 to 0.3
Diffstat (limited to 'app/models/trends/statuses.rb')
-rw-r--r--app/models/trends/statuses.rb7
1 files changed, 4 insertions, 3 deletions
diff --git a/app/models/trends/statuses.rb b/app/models/trends/statuses.rb
index dc5309554..d9b07446e 100644
--- a/app/models/trends/statuses.rb
+++ b/app/models/trends/statuses.rb
@@ -6,7 +6,7 @@ class Trends::Statuses < Trends::Base
   self.default_options = {
     threshold: 5,
     review_threshold: 3,
-    score_halflife: 2.hours.freeze,
+    score_halflife: 6.hours.freeze,
   }
 
   class Query < Trends::Query
@@ -48,7 +48,6 @@ class Trends::Statuses < Trends::Base
   def refresh(at_time = Time.now.utc)
     statuses = Status.where(id: (recently_used_ids(at_time) + currently_trending_ids(false, -1)).uniq).includes(:account, :media_attachments)
     calculate_scores(statuses, at_time)
-    trim_older_items
   end
 
   def request_review
@@ -111,13 +110,15 @@ class Trends::Statuses < Trends::Base
         })
       end
 
+      trim_older_items
+
       # Clean up localized sets by calculating the intersection with the main
       # set. We do this instead of just deleting the localized sets to avoid
       # having moments where the API returns empty results
 
       Trends.available_locales.each do |locale|
         redis.zinterstore("#{key_prefix}:all:#{locale}", ["#{key_prefix}:all:#{locale}", "#{key_prefix}:all"], aggregate: 'max')
-        redis.zinterstore("#{key_prefix}:allowed:#{locale}", ["#{key_prefix}:allowed:#{locale}", "#{key_prefix}:all"], aggregate: 'max')
+        redis.zinterstore("#{key_prefix}:allowed:#{locale}", ["#{key_prefix}:allowed:#{locale}", "#{key_prefix}:allowed"], aggregate: 'max')
       end
     end
   end