added fixture scheduling

This commit is contained in:
2026-02-21 14:19:46 +11:00
parent 23a97787d5
commit b07c486421
13 changed files with 1703 additions and 18 deletions

View File

@@ -32,6 +32,7 @@ func SeasonLeagueTeamDetailPage(
var twr *db.TeamWithRoster
var fixtures []*db.Fixture
var available []*db.Player
var scheduleMap map[int]*db.FixtureSchedule
if ok := conn.WithReadTx(s, w, r, func(ctx context.Context, tx bun.Tx) (bool, error) {
var err error
@@ -47,6 +48,14 @@ func SeasonLeagueTeamDetailPage(
if err != nil {
return false, errors.Wrap(err, "db.GetFixturesForTeam")
}
fixtureIDs := make([]int, len(fixtures))
for i, f := range fixtures {
fixtureIDs[i] = f.ID
}
scheduleMap, err = db.GetAcceptedSchedulesForFixtures(ctx, tx, fixtureIDs)
if err != nil {
return false, errors.Wrap(err, "db.GetAcceptedSchedulesForFixtures")
}
available, err = db.GetPlayersNotOnTeam(ctx, tx, twr.Season.ID, twr.League.ID)
if err != nil {
@@ -58,6 +67,6 @@ func SeasonLeagueTeamDetailPage(
return
}
renderSafely(seasonsview.SeasonLeagueTeamDetailPage(twr, fixtures, available), s, r, w)
renderSafely(seasonsview.SeasonLeagueTeamDetailPage(twr, fixtures, available, scheduleMap), s, r, w)
})
}