Browse Source

make all local statuses trendable and change threshold

closed-social-glitch-2
欧醚 1 year ago
parent
commit
08ae5e6c16
3 changed files with 14 additions and 9 deletions
  1. +1
    -1
      app/models/status.rb
  2. +10
    -5
      app/models/trends/statuses.rb
  3. +3
    -3
      app/models/trends/tags.rb

+ 1
- 1
app/models/status.rb View File

@ -302,7 +302,7 @@ class Status < ApplicationRecord
def trendable?
if attributes['trendable'].nil?
account.trendable?
local? || account.trendable?
else
attributes['trendable']
end

+ 10
- 5
app/models/trends/statuses.rb View File

@ -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]

+ 3
- 3
app/models/trends/tags.rb View File

@ -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,
}

Loading…
Cancel
Save