From 5fac0d4b30c11c9f88eee576b12a2bb167e1a775 Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Sun, 2 Apr 2023 17:24:25 +0200 Subject: [PATCH] Fix gain estimation error due to variable overwrite --- libfic/team.go | 2 +- libfic/team_my.go | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/libfic/team.go b/libfic/team.go index bed743f6..56effa0a 100644 --- a/libfic/team.go +++ b/libfic/team.go @@ -300,7 +300,7 @@ func (t *Team) LastTryDist(e *Exercice) int64 { // HasSolved checks if the Team already has validated the given challenge. // Note that the function also returns the effective validation timestamp. func (t *Team) HasSolved(e *Exercice) (tm *time.Time) { - DBQueryRow("SELECT MIN(time) FROM exercice_solved WHERE id_team = ? AND id_exercice = ?", t.Id, e.Id).Scan(&tm) + DBQueryRow("SELECT time FROM exercice_solved WHERE id_team = ? AND id_exercice = ? ORDER BY time ASC LIMIT 1", t.Id, e.Id).Scan(&tm) return } diff --git a/libfic/team_my.go b/libfic/team_my.go index 197d5743..0b9baf16 100644 --- a/libfic/team_my.go +++ b/libfic/team_my.go @@ -148,8 +148,9 @@ func MyJSONTeam(t *Team, started bool) (interface{}, error) { exercice.Finished = e.Finished exercice.Tries, _ = t.CountTries(e) } else { - exercice.Tries, stime = t.CountTries(e) - exercice.SolvedTime = stime + var ttime *time.Time + exercice.Tries, ttime = t.CountTries(e) + exercice.SolvedTime = ttime if DisplayMCQBadCount && exercice.Tries > 0 { exercice.SolveDist = t.LastTryDist(e) }