added league stats

This commit is contained in:
2026-03-06 21:37:02 +11:00
parent ce659f7d56
commit b96aeef32e
5 changed files with 349 additions and 110 deletions

View File

@@ -25,6 +25,7 @@ func SeasonLeagueStatsPage(
var topGoals []*db.LeagueTopGoalScorer
var topAssists []*db.LeagueTopAssister
var topSaves []*db.LeagueTopSaver
var allStats []*db.LeaguePlayerStats
if ok := conn.WithReadTx(s, w, r, func(ctx context.Context, tx bun.Tx) (bool, error) {
var err error
@@ -52,15 +53,20 @@ func SeasonLeagueStatsPage(
return false, errors.Wrap(err, "db.GetTopSavers")
}
allStats, err = db.GetAllLeaguePlayerStats(ctx, tx, sl.SeasonID, sl.LeagueID)
if err != nil {
return false, errors.Wrap(err, "db.GetAllLeaguePlayerStats")
}
return true, nil
}); !ok {
return
}
if r.Method == "GET" {
renderSafely(seasonsview.SeasonLeagueStatsPage(sl.Season, sl.League, topGoals, topAssists, topSaves), s, r, w)
renderSafely(seasonsview.SeasonLeagueStatsPage(sl.Season, sl.League, topGoals, topAssists, topSaves, allStats), s, r, w)
} else {
renderSafely(seasonsview.SeasonLeagueStats(sl.Season, sl.League, topGoals, topAssists, topSaves), s, r, w)
renderSafely(seasonsview.SeasonLeagueStats(sl.Season, sl.League, topGoals, topAssists, topSaves, allStats), s, r, w)
}
})
}