generated from VLADIMIR/template
fix actions count
This commit is contained in:
@@ -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,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user