Skip to content

Bug: Command Center excludes zero-second completions from average solve time #556

Description

@DevaanshPathak

Component

  • finbot/apps/cc/routes/challenges.py::_challenge_list_with_stats
  • finbot/apps/cc/templates/pages/challenges.html

Problem

The Command Center challenge list excludes completed progress rows when completion_time_seconds is 0:

completed_rows = [
    p
    for p in progress_rows
    if p.status == "completed" and p.completion_time_seconds
]

Zero is a valid completion time. Both challenge-completion paths store the elapsed duration using int(total_seconds()), so any solve completed in under one second is recorded as 0. Because 0 is falsy, these solves are omitted from the average.

The template also uses a truthiness check for avg_solve_seconds, so a valid average of zero is rendered as -.

Steps to reproduce

  1. Pass _challenge_list_with_stats a challenge with one UserChallengeProgress row where:
    • status == "completed"
    • completion_time_seconds == 0
  2. Inspect the returned challenge statistics.

Actual result:

{
    "completions": 1,
    "players": 1,
    "avg_solve_seconds": None,
}

Expected result:

{
    "completions": 1,
    "players": 1,
    "avg_solve_seconds": 0,
}

Impact

Fast first-attempt solves are excluded from the average, biasing solve-time statistics upward. Challenges containing only zero-second completions show recorded completions but no average solve time in the Command Center.

Proposed fix

  • Include completed rows when completion_time_seconds is not None rather than testing its truthiness.
  • In the template, distinguish None from a valid zero value when deciding whether to render the metric.
  • Add regression coverage for zero-second, non-zero, and missing completion times.

Acceptance criteria

  • A completed row with completion_time_seconds=0 contributes to the average.
  • Rows with completion_time_seconds=None remain excluded.
  • A mix of 0 and 10 seconds produces an average of 5 seconds.
  • The challenge list does not render a missing-value marker for a valid zero-second average.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions