mirror of
https://github.com/discourse/discourse.git
synced 2026-08-05 15:18:34 +08:00
Previously, `activity_by_category` aggregated `topics`, `posts` and `topic_view_stats` across the whole reporting window on every dashboard request, and because the category filter was only applied after the join, selecting three categories cost the same as scanning all of them. On a 600k topic / 4.8M post dataset that was ~440ms per request, per admin, growing with the site. This change persists per-day, per-category counts in `category_activity_daily_rollups` and has the report read only those, cutting the same query to ~4ms. `Jobs::MaintainCategoryActivityDailyRollups` refreshes recent days every three hours, while `Jobs::RebuildCategoryActivityDailyRollups` recalculates history daily so topics that are recategorised or deleted after the fact are reattributed rather than left frozen. Invalidating on change was rejected because `PostMover`, bulk category actions, imports and rake tasks all rewrite historical attribution without firing an event. |
||
|---|---|---|
| .. | ||
| engagement_section_spec.rb | ||
| reports_section_spec.rb | ||
| search_section_spec.rb | ||
| site_advice_section_spec.rb | ||
| site_traffic_section_spec.rb | ||