generated from VLADIMIR/template
add times to get game
This commit is contained in:
@@ -10,6 +10,15 @@ import (
|
||||
func mapGame(
|
||||
o *game_service.Game,
|
||||
) *proto.Game {
|
||||
var startedAt *timestamppb.Timestamp
|
||||
if o.StartedAt != nil {
|
||||
startedAt = timestamppb.New(*o.StartedAt)
|
||||
}
|
||||
var endedAt *timestamppb.Timestamp
|
||||
if o.EndedAt != nil {
|
||||
endedAt = timestamppb.New(*o.EndedAt)
|
||||
}
|
||||
|
||||
return &proto.Game{
|
||||
Id: int32(o.ID),
|
||||
Name: o.Name,
|
||||
@@ -18,6 +27,8 @@ func mapGame(
|
||||
Status: o.Status,
|
||||
Scenario: mapScenario(o.Scenario),
|
||||
Teams: mapTeams(o.Teams),
|
||||
StartedAt: startedAt,
|
||||
EndedAt: endedAt,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,4 +13,6 @@ type Game struct {
|
||||
ScenarioId int
|
||||
Scenario *Scenario
|
||||
Teams []*Team
|
||||
StartedAt *time.Time
|
||||
EndedAt *time.Time
|
||||
}
|
||||
|
||||
@@ -62,7 +62,9 @@ func (r *GamesRepo) GetGameByID(
|
||||
games.description,
|
||||
games.start_at,
|
||||
games.status,
|
||||
games.scenario_id
|
||||
games.scenario_id,
|
||||
games.started_at,
|
||||
games.ended_at
|
||||
FROM games
|
||||
WHERE id = $1`,
|
||||
id,
|
||||
@@ -74,6 +76,8 @@ func (r *GamesRepo) GetGameByID(
|
||||
&game.StartAt,
|
||||
&game.Status,
|
||||
&game.ScenarioId,
|
||||
game.StartedAt,
|
||||
game.EndedAt,
|
||||
)
|
||||
if err != nil {
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
|
||||
@@ -13,4 +13,6 @@ type Game struct {
|
||||
Status string
|
||||
Scenario *scenarios_service.Scenario
|
||||
Teams []*Team
|
||||
StartedAt *time.Time
|
||||
EndedAt *time.Time
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@ func mapGame(
|
||||
Status: o.Status,
|
||||
Scenario: scenarios_service.MapScenarioLight(o.Scenario, domain),
|
||||
Teams: mapTeams(o.Teams),
|
||||
StartedAt: o.StartedAt,
|
||||
EndedAt: o.EndedAt,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user