38 lines
1.2 KiB
Go
38 lines
1.2 KiB
Go
package sorare_utils
|
|
|
|
import (
|
|
"git.lehouerou.net/laurent/sorare/football"
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
|
|
"git.lehouerou.net/laurent/sorarebuddy/model"
|
|
)
|
|
|
|
func NewCreateOrUpdateGamesParamsFromSorare(game football.Game) model.CreateOrUpdateGamesParams {
|
|
return model.CreateOrUpdateGamesParams{
|
|
ID: game.Id.Value,
|
|
Date: pgtype.Timestamptz{Time: game.Date, Valid: true},
|
|
CoverageStatus: game.CoverageStatus,
|
|
LowCoverage: game.LowCoverage,
|
|
Minutes: int32(game.Minute),
|
|
PeriodType: game.PeriodType,
|
|
Scored: game.Scored,
|
|
Status: game.Status,
|
|
CompetitionSlug: game.Competition.Slug,
|
|
FixtureSlug: game.So5Fixture.Slug,
|
|
AwayTeamSlug: game.AwayTeam.Team.Slug,
|
|
AwayGoals: int32(game.AwayGoals),
|
|
AwayExtraTimeScore: int32(game.ExtraTimeScoreAway),
|
|
AwayPenaltyScore: int32(game.PenaltyScoreAway),
|
|
HomeTeamSlug: game.HomeTeam.Team.Slug,
|
|
HomeGoals: int32(game.HomeGoals),
|
|
HomeExtraTimeScore: int32(game.ExtraTimeScoreHome),
|
|
HomePenaltyScore: int32(game.PenaltyScoreHome),
|
|
WinnerTeamSlug: func() *string {
|
|
if game.Winner.Team.Slug == "" {
|
|
return nil
|
|
}
|
|
return &game.Winner.Team.Slug
|
|
}(),
|
|
}
|
|
}
|