added league table

This commit is contained in:
2026-02-21 23:11:57 +11:00
parent 1c93a707ab
commit 4185ab58e2
6 changed files with 242 additions and 22 deletions

View File

@@ -127,6 +127,22 @@ func GetFixture(ctx context.Context, tx bun.Tx, id int) (*Fixture, error) {
Get(ctx)
}
// GetAllocatedFixtures returns all fixtures with a game_week assigned for a season+league.
func GetAllocatedFixtures(ctx context.Context, tx bun.Tx, seasonID, leagueID int) ([]*Fixture, error) {
fixtures, err := GetList[Fixture](tx).
Where("season_id = ?", seasonID).
Where("league_id = ?", leagueID).
Where("game_week IS NOT NULL").
Order("game_week ASC", "round ASC", "id ASC").
Relation("HomeTeam").
Relation("AwayTeam").
GetAll(ctx)
if err != nil {
return nil, errors.Wrap(err, "GetList")
}
return fixtures, nil
}
func GetFixturesForTeam(ctx context.Context, tx bun.Tx, seasonID, leagueID, teamID int) ([]*Fixture, error) {
fixtures, err := GetList[Fixture](tx).
Where("season_id = ?", seasonID).