mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-03 06:36:23 +08:00
The existing "Votes" sort orders topics by all-time vote count, which causes old, resolved topics to permanently dominate the list. Communities using the voting plugin have been asking for a way to surface topics gaining traction *recently* since 2016. This adds a "Trending" sort that uses a time-decay formula where each vote contributes `1 / (age_in_hours + 2)` to the topic's trending score. Recent votes naturally weigh more — a vote cast 1 hour ago scores ~0.33 while a vote cast 30 days ago scores ~0.001. No windows, thresholds, or scheduled jobs needed. The sort is available via `?order=votes-trending` on topic lists and through the new "Trending" navigation tab in voting-enabled categories. It also works with the TopicsFilter query string (`order:votes-trending`). All-time vote count is used as a tiebreaker, then bumped_at. A composite index on `(topic_id, created_at)` is added to `topic_voting_votes` to keep the correlated subquery fast. The JS initializer is also refactored to reduce duplication across the three voting navigation bar items. Ref - t/180396 |
||
|---|---|---|
| .. | ||
| 20190625085735_add_vote_count_index_to_topic_custom_fields.rb | ||
| 20190718152804_reclaim_from_disabled_category.rb | ||
| 20200727220143_create_discourse_voting_category_settings.rb | ||
| 20200728222920_create_discourse_voting_votes.rb | ||
| 20200729042607_create_discourse_voting_topic_vote_count.rb | ||
| 20201003141123_remove_votes_of_deleted_users.rb | ||
| 20240707170311_rename_voting_tables.rb | ||
| 20240711102255_ensure_consistency.rb | ||
| 20240715021442_rename_topic_voting_site_settings.rb | ||
| 20240717071658_update_data_explorer_topic_voting_queries.rb | ||
| 20240807020209_rename_incorrect_topic_voting_site_settings.rb | ||
| 20241203125415_rename_reassign_sequences.rb | ||
| 20241203125523_drop_old_discourse_voting_tables.rb | ||
| 20241210081242_rename_sequences.rb | ||
| 20251209012613_add_vote_counts_index.rb | ||
| 20260324200000_add_topic_id_created_at_index_to_topic_voting_votes.rb | ||