From 08ae5e6c168b4d8adb215a3c2e1e52842ed3a747 Mon Sep 17 00:00:00 2001 From: Tdxdxoz Date: Sat, 25 Mar 2023 21:09:10 +0800 Subject: [PATCH] make all local statuses trendable and change threshold --- app/models/status.rb | 2 +- app/models/trends/statuses.rb | 15 ++++++++++----- app/models/trends/tags.rb | 6 +++--- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/app/models/status.rb b/app/models/status.rb index 33c45804a..e3c2f7bd6 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -302,7 +302,7 @@ class Status < ApplicationRecord def trendable? if attributes['trendable'].nil? - account.trendable? + local? || account.trendable? else attributes['trendable'] end diff --git a/app/models/trends/statuses.rb b/app/models/trends/statuses.rb index d4d5b1c24..0acd2ad8b 100644 --- a/app/models/trends/statuses.rb +++ b/app/models/trends/statuses.rb @@ -4,10 +4,15 @@ class Trends::Statuses < Trends::Base PREFIX = 'trending_statuses' self.default_options = { - threshold: 5, - review_threshold: 3, - score_halflife: 2.hours.freeze, - decay_threshold: 0.3, + threshold: 10, + review_threshold: 10, + score_halflife: 12.hours.freeze, + decay_threshold: 1.8, + expected: 5.0, + # (11 - 5)^2 / 5 * 0.5^2 = 1.8 + # so a status with 11 favourites can stay 24hours + # 17 favourites, 2 days + # 29 favourites, 3 days } class Query < Trends::Query @@ -96,7 +101,7 @@ class Trends::Statuses < Trends::Base def calculate_scores(statuses, at_time) items = statuses.map do |status| - expected = 1.0 + expected = options[:expected] observed = (status.reblogs_count + status.favourites_count).to_f score = if expected > observed || observed < options[:threshold] diff --git a/app/models/trends/tags.rb b/app/models/trends/tags.rb index 931532990..eebbb254f 100644 --- a/app/models/trends/tags.rb +++ b/app/models/trends/tags.rb @@ -4,10 +4,10 @@ class Trends::Tags < Trends::Base PREFIX = 'trending_tags' self.default_options = { - threshold: 5, - review_threshold: 3, + threshold: 2, + review_threshold: 2, max_score_cooldown: 2.days.freeze, - max_score_halflife: 4.hours.freeze, + max_score_halflife: 12.hours.freeze, decay_threshold: 1, }