sorarebuddy/sorare_utils/game.go

37 lines
1.1 KiB
Go
Raw Permalink Normal View History

package sorare_utils
import (
"git.lehouerou.net/laurent/sorare/football"
"git.lehouerou.net/laurent/sorarebuddy/model"
)
2024-05-23 04:18:54 +00:00
func NewGameFromSorare(game football.Game) model.Game {
return model.Game{
Id: game.Id.Value,
Date: game.Date,
CoverageStatus: game.CoverageStatus,
LowCoverage: game.LowCoverage,
2024-05-23 04:18:54 +00:00
Minutes: int(game.Minute),
PeriodType: game.PeriodType,
Scored: game.Scored,
Status: game.Status,
CompetitionSlug: game.Competition.Slug,
FixtureSlug: game.So5Fixture.Slug,
AwayTeamSlug: game.AwayTeam.Team.Slug,
2024-05-23 04:18:54 +00:00
AwayGoals: int(game.AwayGoals),
AwayExtraTimeScore: int(game.ExtraTimeScoreAway),
AwayPenaltyScore: int(game.PenaltyScoreAway),
HomeTeamSlug: game.HomeTeam.Team.Slug,
2024-05-23 04:18:54 +00:00
HomeGoals: int(game.HomeGoals),
HomeExtraTimeScore: int(game.ExtraTimeScoreHome),
HomePenaltyScore: int(game.PenaltyScoreHome),
WinnerTeamSlug: func() *string {
if game.Winner.Team.Slug == "" {
return nil
}
return &game.Winner.Team.Slug
}(),
}
}