-
Notifications
You must be signed in to change notification settings - Fork 157
Open
Description
Summary
The background stats worker currently only calculates stats at the dojo level (calculate_dojo_stats in dojo_plugin/worker/handlers/dojo_stats.py). We should extend it to also calculate and cache stats at the module level, then display them on the module page.
What exists today
- Dojo-level stats: calculated by the background worker, cached in Redis (
stats:dojo:{reference_id}), displayed viastat_dashboard.htmlondojo.html - Module-level:
module.solves()exists and can scope queries to a single module, but no stats are calculated or cached for modules - Module page: shows per-challenge solve counts and a scoreboard, but no aggregate stats dashboard
What needs to be done
Backend
- Add
calculate_module_stats(module)function (similar tocalculate_dojo_statsbut usingmodule.solves()) - Add a module stats event handler in the worker (e.g.,
handle_module_stats_update) - Cache module stats in Redis with key pattern
stats:module:{dojo_reference_id}:{module_id} - Fan out stats events to affected modules when solves happen (the listener already triggers on solve inserts)
- Add
get_module_stats(module)retrieval function indojo_plugin/utils/stats.py
Frontend
- Pass module stats from
view_module()indojo_plugin/pages/dojo.pytomodule.html - Make
stat_dashboard.htmlgeneric enough to render for either a dojo or a module (e.g., parameterize the header, conditionally show/hide cards like "Recent Awardees" which are dojo-specific) - Include the stats dashboard on
module.html
Stats to include per module
- Total Solves, Unique Hackers, Challenges count, Hacking Now (from container stats)
- Activity History chart (daily solves/users at snapshot intervals)
- Recent Solves
- Trend indicators (week-over-week changes)
Key files
dojo_plugin/worker/handlers/dojo_stats.py- stats calculation and worker handlerdojo_plugin/utils/stats.py- stats retrievaldojo_plugin/utils/listeners.py- event triggersdojo_plugin/utils/events.py- event publishingdojo_plugin/pages/dojo.py-view_module()controllerdojo_theme/templates/module.html- module page templatedojo_theme/templates/components/stat_dashboard.html- stats dashboard component
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels