From e526f42ac3aaf68edb882ee0a4bd5c23a3dc02a0 Mon Sep 17 00:00:00 2001 From: Haelnorr Date: Fri, 6 Mar 2026 18:23:37 +1100 Subject: [PATCH] added periods played --- internal/db/fixture_result.go | 22 ++++++++++--------- .../view/seasonsview/fixture_detail.templ | 4 +++- .../seasonsview/fixture_review_result.templ | 4 +++- .../season_league_team_detail.templ | 2 ++ 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/internal/db/fixture_result.go b/internal/db/fixture_result.go index 390d69e..002daf1 100644 --- a/internal/db/fixture_result.go +++ b/internal/db/fixture_result.go @@ -381,16 +381,17 @@ func GetFinalizedResultsForFixtures(ctx context.Context, tx bun.Tx, fixtureIDs [ // AggregatedPlayerStats holds summed stats for a player across multiple fixtures. type AggregatedPlayerStats struct { - PlayerID int `bun:"player_id"` - PlayerName string `bun:"player_name"` - GamesPlayed int `bun:"games_played"` - Score int `bun:"total_score"` - Goals int `bun:"total_goals"` - Assists int `bun:"total_assists"` - Saves int `bun:"total_saves"` - Shots int `bun:"total_shots"` - Blocks int `bun:"total_blocks"` - Passes int `bun:"total_passes"` + PlayerID int `bun:"player_id"` + PlayerName string `bun:"player_name"` + GamesPlayed int `bun:"games_played"` + PeriodsPlayed int `bun:"total_periods_played"` + Score int `bun:"total_score"` + Goals int `bun:"total_goals"` + Assists int `bun:"total_assists"` + Saves int `bun:"total_saves"` + Shots int `bun:"total_shots"` + Blocks int `bun:"total_blocks"` + Passes int `bun:"total_passes"` } // GetAggregatedPlayerStatsForTeam returns aggregated period-3 stats for all mapped @@ -411,6 +412,7 @@ func GetAggregatedPlayerStatsForTeam( frps.player_id AS player_id, COALESCE(p.name, frps.player_username) AS player_name, COUNT(DISTINCT frps.fixture_result_id) AS games_played, + COALESCE(SUM(frps.periods_played), 0) AS total_periods_played, COALESCE(SUM(frps.score), 0) AS total_score, COALESCE(SUM(frps.goals), 0) AS total_goals, COALESCE(SUM(frps.assists), 0) AS total_assists, diff --git a/internal/view/seasonsview/fixture_detail.templ b/internal/view/seasonsview/fixture_detail.templ index cc33e2e..c9d34cc 100644 --- a/internal/view/seasonsview/fixture_detail.templ +++ b/internal/view/seasonsview/fixture_detail.templ @@ -662,6 +662,7 @@ templ fixtureTeamSection(team *db.Team, players []*db.PlayerWithPlayStatus, side Player + PP SC G A @@ -690,6 +691,7 @@ templ fixtureTeamSection(team *db.Team, players []*db.PlayerWithPlayStatus, side if p.Stats != nil { + { intPtrStr(p.Stats.PeriodsPlayed) } { intPtrStr(p.Stats.Score) } { intPtrStr(p.Stats.Goals) } { intPtrStr(p.Stats.Assists) } @@ -698,7 +700,7 @@ templ fixtureTeamSection(team *db.Team, players []*db.PlayerWithPlayStatus, side { intPtrStr(p.Stats.Blocks) } { intPtrStr(p.Stats.Passes) } } else { - — + — } } diff --git a/internal/view/seasonsview/fixture_review_result.templ b/internal/view/seasonsview/fixture_review_result.templ index 8ac5308..e01796b 100644 --- a/internal/view/seasonsview/fixture_review_result.templ +++ b/internal/view/seasonsview/fixture_review_result.templ @@ -205,6 +205,7 @@ templ reviewTeamStats(team *db.Team, result *db.FixtureResult, side string) { Player + PP G A SV @@ -230,6 +231,7 @@ templ reviewTeamStats(team *db.Team, result *db.FixtureResult, side string) { } + { intPtrStr(ps.Stats.PeriodsPlayed) } { intPtrStr(ps.Stats.Goals) } { intPtrStr(ps.Stats.Assists) } { intPtrStr(ps.Stats.Saves) } @@ -241,7 +243,7 @@ templ reviewTeamStats(team *db.Team, result *db.FixtureResult, side string) { } if len(finalStats) == 0 { - + No player stats recorded diff --git a/internal/view/seasonsview/season_league_team_detail.templ b/internal/view/seasonsview/season_league_team_detail.templ index ad1dedf..0022edd 100644 --- a/internal/view/seasonsview/season_league_team_detail.templ +++ b/internal/view/seasonsview/season_league_team_detail.templ @@ -617,6 +617,7 @@ templ teamStatsSection(record *db.TeamRecord, playerStats []*db.AggregatedPlayer Player GP + PP SC G A @@ -631,6 +632,7 @@ templ teamStatsSection(record *db.TeamRecord, playerStats []*db.AggregatedPlayer { ps.PlayerName } { fmt.Sprint(ps.GamesPlayed) } + { fmt.Sprint(ps.PeriodsPlayed) } { fmt.Sprint(ps.Score) } { fmt.Sprint(ps.Goals) } { fmt.Sprint(ps.Assists) }