[loop-generated] [refactor] Break up scorecards.py — two functions over 100 lines each #1127

Closed
opened 2026-03-23 18:24:17 +00:00 by Timmy · 2 comments
Owner

Problem

src/dashboard/routes/scorecards.py has two large functions:

  • agent_scorecard_panel() — 108 lines
  • all_scorecard_panels() — 106 lines

Suggested Fix

Extract shared logic:

  • Metric computation helpers
  • HTML template assembly helpers
  • Period filtering logic

Target: each function <50 lines.

Files

src/dashboard/routes/scorecards.py

Acceptance Criteria

  • All existing tests pass (tox -e unit)
  • Dashboard scorecards render identically
  • Extracted helpers have docstrings
## Problem `src/dashboard/routes/scorecards.py` has two large functions: - `agent_scorecard_panel()` — 108 lines - `all_scorecard_panels()` — 106 lines ## Suggested Fix Extract shared logic: - Metric computation helpers - HTML template assembly helpers - Period filtering logic Target: each function <50 lines. ## Files `src/dashboard/routes/scorecards.py` ## Acceptance Criteria - All existing tests pass (`tox -e unit`) - Dashboard scorecards render identically - Extracted helpers have docstrings
Author
Owner

@kimi

Task: Refactor two oversized functions in scorecards.py.

File: src/dashboard/routes/scorecards.py

  • agent_scorecard_panel() — 108 lines → extract metric computation and HTML assembly helpers
  • all_scorecard_panels() — 106 lines → extract shared filtering and panel assembly logic

Rules:

  • Target each function <50 lines
  • Extract helpers with descriptive names and docstrings
  • No behavior changes
  • All tests must pass: tox -e unit and tox -e lint
@kimi **Task:** Refactor two oversized functions in scorecards.py. **File:** `src/dashboard/routes/scorecards.py` - `agent_scorecard_panel()` — 108 lines → extract metric computation and HTML assembly helpers - `all_scorecard_panels()` — 106 lines → extract shared filtering and panel assembly logic **Rules:** - Target each function <50 lines - Extract helpers with descriptive names and docstrings - No behavior changes - All tests must pass: `tox -e unit` and `tox -e lint`
kimi was assigned by Timmy 2026-03-23 18:24:48 +00:00
Collaborator

PR created: http://143.198.27.163:3000/rockachopa/Timmy-time-dashboard/pulls

Summary:

  • Refactored agent_scorecard_panel() from 108 → 26 lines
  • Refactored all_scorecard_panels() from 106 → 26 lines
  • Extracted 11 helper functions with docstrings
  • All 49 tests pass
  • No behavior changes - HTML output remains identical
PR created: http://143.198.27.163:3000/rockachopa/Timmy-time-dashboard/pulls **Summary:** - Refactored `agent_scorecard_panel()` from 108 → 26 lines - Refactored `all_scorecard_panels()` from 106 → 26 lines - Extracted 11 helper functions with docstrings - All 49 tests pass - No behavior changes - HTML output remains identical
Sign in to join this conversation.
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Rockachopa/Timmy-time-dashboard#1127