add times to get game

This commit is contained in:
2026-08-04 01:23:01 +07:00
parent ae3a8c809f
commit f3ac19ed83
9 changed files with 159 additions and 104 deletions
+11
View File
@@ -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,
}
}
+2
View File
@@ -13,4 +13,6 @@ type Game struct {
ScenarioId int
Scenario *Scenario
Teams []*Team
StartedAt *time.Time
EndedAt *time.Time
}
+5 -1
View File
@@ -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) {
+2
View File
@@ -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,
}
}