Implement real-time counts tracking with running statistics #81
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The counts tables track usage metrics (submissions, runs, errors, edit times) but weren't being populated. Performance requires instant statistics computation without aggregating historical logs.
Changes
Model Relationships
Submission.submission_counts,Assignment.counts,Course.counts,User.user_countsTracking Helpers (
models/counters/helpers.py)new_avg = old_avg + (new_value - old_avg) / countupdate_run_count(),update_error_counts(),increment_submission_count(),update_user_activity()recalculate_submission_counts_from_logs()for existing dataIntegration Points
Submission.from_assignment()- increment submission counts across assignment/course/usersave_student_file()- update user edit timestamplog_event()- track runs and error types (syntax/runtime/instructor test)Assignment.new()- increment course assignment countUser.add_role(),User.update_roles()- track course enrollment by rolehandle_login_change()- update last login timestampUsage
Metrics are updated incrementally in O(1) time. The recalculation function uses ILIKE queries suitable for one-time backfilling but not real-time use.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.