fix actions count

This commit is contained in:
2026-10-01 02:03:37 +07:00
parent 85d94edbe8
commit 732f898cf0
2 changed files with 12 additions and 2 deletions
+11 -1
View File
@@ -167,6 +167,14 @@ func (s *AnswerService) GetGameAnswers(ctx context.Context, gameId int) (*GameAn
if err != nil {
return nil, err
}
teamIds := make([]int, 0, len(teams))
for _, team := range teams {
teamIds = append(teamIds, team.ID)
}
actionsCountByTeamIDs, err := s.actionsRepo.GetActionsCountByTeamIDs(ctx, teamIds)
if err != nil {
return nil, err
}
rows, err := s.answersRepo.GetAnswersByGameID(ctx, gameId)
if err != nil {
return nil, err
@@ -199,8 +207,10 @@ func (s *AnswerService) GetGameAnswers(ctx context.Context, gameId int) (*GameAn
}
answers = append(answers, AnswerScore{QuestionCode: question.Code})
}
mappedTeam := game_model.MapTeam(team)
mappedTeam.ActionsCount = actionsCountByTeamIDs[team.ID]
teamAnswers = append(teamAnswers, TeamAnswers{
Team: game_model.MapTeam(team),
Team: mappedTeam,
Answers: answers,
})
}