mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-07 00:37:22 +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 |
||
|---|---|---|
| .. | ||
| migrate | ||