From 1bcd4819da65ed012f7de660934105f24a0de7c0 Mon Sep 17 00:00:00 2001 From: Matthew Spah Date: Fri, 25 Sep 2026 08:18:29 -0700 Subject: [PATCH 1/2] refactor: clarify team presentation ownership --- app/web/templates/_summary_cards.html | 9 +++++++++ ...selector_form.html => _team_selector_form.html} | 6 +++--- app/web/templates/baserunners.html | 12 ++---------- app/web/templates/comparison.html | 14 ++++---------- app/web/templates/hits_allowed.html | 12 ++---------- app/web/templates/index.html | 12 ++---------- app/web/templates/pitching.html | 12 ++---------- app/web/templates/run_differential.html | 12 ++---------- app/web/templates/runs.html | 12 ++---------- app/web/templates/strikeouts.html | 12 ++---------- docs/ui-information-architecture.md | 6 ++++++ tests/test_web.py | 2 ++ tests/test_web_comparison.py | 4 ++++ tests/test_web_page_scaffolding.py | 10 ++++++++++ 14 files changed, 52 insertions(+), 83 deletions(-) create mode 100644 app/web/templates/_summary_cards.html rename app/web/templates/{_selector_form.html => _team_selector_form.html} (90%) diff --git a/app/web/templates/_summary_cards.html b/app/web/templates/_summary_cards.html new file mode 100644 index 0000000..036a8c4 --- /dev/null +++ b/app/web/templates/_summary_cards.html @@ -0,0 +1,9 @@ +
+ {% for card in summary_cards %} +
+

{{ card.label }}

+

{{ card.value }}

+

{{ card.caption }}

+
+ {% endfor %} +
diff --git a/app/web/templates/_selector_form.html b/app/web/templates/_team_selector_form.html similarity index 90% rename from app/web/templates/_selector_form.html rename to app/web/templates/_team_selector_form.html index 53abacd..75ce4f2 100644 --- a/app/web/templates/_selector_form.html +++ b/app/web/templates/_team_selector_form.html @@ -1,6 +1,6 @@ -{# Shared team/season/window controls. Both metric pages post to their own path - via form_action, so one selector serves both without a second selection - system. The route validates the team-season pair on every request. #} +{# Team-only GET controls for team_id, season, and window. Each Team metric + supplies form_action; the Team-season catalog supports season-selector.js. + Routes validate the Team-season pair even without JavaScript. #}
diff --git a/app/web/templates/baserunners.html b/app/web/templates/baserunners.html index 073ed83..3ae94a6 100644 --- a/app/web/templates/baserunners.html +++ b/app/web/templates/baserunners.html @@ -34,7 +34,7 @@

No team data has been imported yet

{{ import_command }}
{% else %} - {% include "_selector_form.html" %} + {% include "_team_selector_form.html" %} {% if state == "not_found" %}
@@ -72,15 +72,7 @@

{{ analysis.team_name }} — Baserunners per Game

{{ chart_html | safe }}
-
- {% for card in summary_cards %} -
-

{{ card.label }}

-

{{ card.value }}

-

{{ card.caption }}

-
- {% endfor %} -
+ {% include "_summary_cards.html" %}
{% else %} - {% include "_selector_form.html" %} + {% include "_team_selector_form.html" %} {% if state == "not_found" %}
@@ -65,15 +65,9 @@

{{ analysis.team_name }} — Hits vs Batting Strikeouts

-
- {% for card in summary_cards %} -
-

{{ card.label }}

-

{{ card.value }}

-

{{ card.caption }}

-
- {% endfor %} -
+ {% with summary_class="summary summary--comparison", summary_label="Comparison summary statistics" %} + {% include "_summary_cards.html" %} + {% endwith %}
{% else %} - {% include "_selector_form.html" %} + {% include "_team_selector_form.html" %} {% if state == "not_found" %}
@@ -72,15 +72,7 @@

{{ analysis.team_name }} — Hits Allowed per Game

{{ chart_html | safe }}
-
- {% for card in summary_cards %} -
-

{{ card.label }}

-

{{ card.value }}

-

{{ card.caption }}

-
- {% endfor %} -
+ {% include "_summary_cards.html" %}
{% else %} - {% include "_selector_form.html" %} + {% include "_team_selector_form.html" %} {% if state == "not_found" %}
@@ -51,15 +51,7 @@

{{ analysis.team_name }} — Hits per Game

{{ chart_html | safe }}
-
- {% for card in summary_cards %} -
-

{{ card.label }}

-

{{ card.value }}

-

{{ card.caption }}

-
- {% endfor %} -
+ {% include "_summary_cards.html" %}
{% else %} - {% include "_selector_form.html" %} + {% include "_team_selector_form.html" %} {% if state == "not_found" %}
@@ -71,15 +71,7 @@

{{ analysis.team_name }} — Pitches per Game

{{ chart_html | safe }}
-
- {% for card in summary_cards %} -
-

{{ card.label }}

-

{{ card.value }}

-

{{ card.caption }}

-
- {% endfor %} -
+ {% include "_summary_cards.html" %}
{% else %} - {% include "_selector_form.html" %} + {% include "_team_selector_form.html" %} {% if state == "not_found" %}
@@ -73,15 +73,7 @@

{{ analysis.team_name }} — Run Differential per Game

{{ chart_html | safe }}
-
- {% for card in summary_cards %} -
-

{{ card.label }}

-

{{ card.value }}

-

{{ card.caption }}

-
- {% endfor %} -
+ {% include "_summary_cards.html" %}
{% else %} - {% include "_selector_form.html" %} + {% include "_team_selector_form.html" %} {% if state == "not_found" %}
@@ -51,15 +51,7 @@

{{ analysis.team_name }} — Runs Scored per Game

{{ chart_html | safe }}
-
- {% for card in summary_cards %} -
-

{{ card.label }}

-

{{ card.value }}

-

{{ card.caption }}

-
- {% endfor %} -
+ {% include "_summary_cards.html" %}
{% else %} - {% include "_selector_form.html" %} + {% include "_team_selector_form.html" %} {% if state == "not_found" %}
@@ -70,15 +70,7 @@

{{ analysis.team_name }} — Batting Strikeouts per Game

{{ chart_html | safe }}
-
- {% for card in summary_cards %} -
-

{{ card.label }}

-

{{ card.value }}

-

{{ card.caption }}

-
- {% endfor %} -
+ {% include "_summary_cards.html" %}