read the best solution for each task in contest
This commit is contained in:
parent
b1dae9c2ec
commit
e3628f2e4a
5 changed files with 82 additions and 1 deletions
|
@ -99,6 +99,15 @@ func (h *TesterHandlers) GetContest(c *fiber.Ctx, id int32) error {
|
|||
return c.SendStatus(pkg.ToREST(err))
|
||||
}
|
||||
|
||||
var participantId int32 = 2
|
||||
|
||||
solutions, err := h.contestsUC.ReadBestSolutions(c.Context(), id, participantId)
|
||||
|
||||
m := make(map[int32]*models.Solution)
|
||||
|
||||
for i := 0; i < len(solutions); i++ {
|
||||
m[solutions[i].TaskPosition] = solutions[i]
|
||||
}
|
||||
resp := testerv1.GetContestResponse{
|
||||
Contest: C2C(*contest),
|
||||
Tasks: make([]struct {
|
||||
|
@ -108,11 +117,15 @@ func (h *TesterHandlers) GetContest(c *fiber.Ctx, id int32) error {
|
|||
}
|
||||
|
||||
for i, task := range tasks {
|
||||
solution := testerv1.Solution{}
|
||||
if sol, ok := m[task.Position]; ok {
|
||||
solution = S2S(*sol)
|
||||
}
|
||||
resp.Tasks[i] = struct {
|
||||
Solution testerv1.Solution `json:"solution"`
|
||||
Task testerv1.TasksListItem `json:"task"`
|
||||
}{
|
||||
Solution: testerv1.Solution{},
|
||||
Solution: solution,
|
||||
Task: TLI2TLI(*task),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue