1,040
edits
(Created page with "Up to: Part Of::Features Trending posts and hashtags to help with content discoverability! == Usage == Go to the [https://neuromatch.social/explore Explore] tab! From there you are given four menus, * Posts * Hashtags * People * News (popular links) == Implementation == Trends are defined in a family of models in <code>mastodon/app/models/trends</code>: https://github.com/NeuromatchAcademy/mastodon/tree/main/app/models/trends Eg. for <code>Statuses</code> th...") |
|||
Line 21: | Line 21: | ||
<syntaxhighlight lang="ruby"> | <syntaxhighlight lang="ruby"> | ||
def calculate_scores(statuses, at_time) | |||
items = statuses.map do |status| | |||
expected = 1.0 | |||
observed = (status.reblogs_count + status.favourites_count).to_f | |||
score = if expected > observed || observed < options[:threshold] | |||
0 | |||
else | |||
((observed - expected)**2) / expected | |||
end | |||
decaying_score = if score.zero? || !eligible?(status) | |||
0 | |||
else | |||
score * (0.5**((at_time.to_f - status.created_at.to_f) / options[:score_halflife].to_f)) | |||
end | |||
[decaying_score, status] | |||
end | |||
</syntaxhighlight> | </syntaxhighlight> | ||
AKA the score is a sum of reblogs and favorites with some exponential time decay. | AKA the score is a sum of reblogs and favorites with some exponential time decay. | ||
== Config == | == Config == |