fix(cc): include zero-second challenge solves - #557
Open
DevaanshPathak wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes Command Center challenge statistics and rendering so legitimate 0-second solve durations are treated as valid values (not missing), ensuring fast solves contribute to averages and zero averages render as 0m instead of a missing marker.
Changes:
- Update
_challenge_list_with_statsto include completed rows wherecompletion_time_seconds == 0by filtering onis not None. - Update the CC challenges template to render averages when
avg_solve_secondsis0(distinguishingNonevs0). - Add regression tests covering zero, non-zero, and missing durations, including a real template render assertion.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
finbot/apps/cc/routes/challenges.py |
Fixes stats calculation to include zero-second completed solves in average computation. |
finbot/apps/cc/templates/pages/challenges.html |
Renders 0m for a valid zero average by checking is not none rather than truthiness. |
tests/unit/apps/cc/test_challenges.py |
Adds unit/regression coverage for the zero-duration edge case and template rendering. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Root cause
The statistics helper and template both used truthiness checks for solve durations. Challenge completion stores elapsed time as an integer, so a legitimate sub-second solve becomes
0and was treated as if the value were missing.Impact
Fast solves now contribute to average solve-time statistics instead of biasing averages upward. Challenges with a valid zero-second average display
0mrather than a missing-value marker.Testing
uv run pytest tests/unit/apps/cc/test_challenges.py— 3 passeduv run pytest tests/unit/apps— 16 passeduv run black --check tests/unit/apps/cc/test_challenges.pyuv run isort --check-only finbot/apps/cc/routes/challenges.py tests/unit/apps/cc/test_challenges.pyFixes #556