sorarebuddy/model/game.go

41 lines
2.2 KiB
Go
Raw Normal View History

2024-05-23 04:18:54 +00:00
package model
import (
"fmt"
"time"
)
type Game struct {
Id string `bun:"id,pk" json:"id"`
Date time.Time `bun:"date" json:"date"`
CoverageStatus string `bun:"coverage_status" json:"coverageStatus"`
LowCoverage bool `bun:"low_coverage" json:"lowCoverage"`
Minutes int `bun:"minutes" json:"minutes"`
PeriodType string `bun:"period_type" json:"periodType"`
Scored bool `bun:"scored" json:"scored"`
Status string `bun:"status" json:"status"`
CompetitionSlug string `bun:"competition_slug" json:"competitionSlug"`
FixtureSlug string `bun:"fixture_slug" json:"fixtureSlug"`
AwayTeamSlug string `bun:"away_team_slug" json:"awayTeamSlug"`
AwayGoals int `bun:"away_goals" json:"awayGoals"`
AwayExtraTimeScore int `bun:"away_extra_time_score" json:"awayExtraTimeScore"`
AwayPenaltyScore int `bun:"away_penalty_score" json:"awayPenaltyScore"`
HomeTeamSlug string `bun:"home_team_slug" json:"homeTeamSlug"`
HomeGoals int `bun:"home_goals" json:"homeGoals"`
HomeExtraTimeScore int `bun:"home_extra_time_score" json:"homeExtraTimeScore"`
HomePenaltyScore int `bun:"home_penalty_score" json:"homePenaltyScore"`
WinnerTeamSlug *string `bun:"winner_team_slug" json:"winnerTeamSlug"`
HomeTeam *Team `bun:"rel:has-one,join:home_team_slug=slug" json:"homeTeam"`
AwayTeam *Team `bun:"rel:has-one,join:away_team_slug=slug" json:"awayTeam"`
WinnerTeam *Team `bun:"rel:has-one,join:winner_team_slug=slug" json:"winnerTeam"`
Competition *Competition `bun:"rel:has-one,join:competition_slug=slug" json:"competition"`
GamePlayers []GamePlayer `bun:"rel:has-many,join:id=game_id" json:"gamePlayers"`
Fixture *Fixture `bun:"rel:has-one,join:fixture_slug=slug" json:"fixture"`
}
func (g *Game) String() string {
return fmt.Sprintf("%s %s <-> %s", g.Date.Format("2006-01-02"), g.HomeTeam.DisplayName, g.AwayTeam.DisplayName)
}