fic: Refactor CountTries function to fix timeouted submission
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
40a9b0d187
commit
7a7f90eeda
|
@ -246,28 +246,23 @@ func (t *Team) DisplayChoices(k *FlagKey) error {
|
|||
}
|
||||
|
||||
// CountTries gets the amount of attempts made by the Team and retrieves the time of the latest attempt.
|
||||
func (t *Team) CountTries(e *Exercice) (int64, *time.Time) {
|
||||
func (t *Team) CountTries(e *Exercice) (nb int64, tm *time.Time) {
|
||||
table := "exercice_tries"
|
||||
if SubmissionUniqueness {
|
||||
table = "exercice_distinct_tries"
|
||||
}
|
||||
if CountOnlyNotGoodTries {
|
||||
table += "_notgood"
|
||||
}
|
||||
|
||||
var nb *int64
|
||||
var tm *time.Time
|
||||
if DBQueryRow("SELECT COUNT(id_exercice), MAX(time) FROM "+table+" WHERE id_team = ? AND id_exercice = ?", t.Id, e.Id).Scan(&nb, &tm); tm == nil {
|
||||
if CountOnlyNotGoodTries {
|
||||
if DBQueryRow("SELECT COUNT(id_exercice), MAX(time) FROM exercice_tries WHERE id_team = ? AND id_exercice = ?", t.Id, e.Id).Scan(&nb, &tm); tm == nil {
|
||||
return 0, nil
|
||||
} else {
|
||||
return 0, tm
|
||||
}
|
||||
}
|
||||
return 0, nil
|
||||
} else if nb == nil {
|
||||
return 0, tm
|
||||
} else {
|
||||
return *nb, tm
|
||||
DBQueryRow("SELECT COUNT(id_exercice), MAX(time) FROM "+table+" WHERE id_team = ? AND id_exercice = ?", t.Id, e.Id).Scan(&nb, &tm)
|
||||
|
||||
// time is not accurate in distinct nor _notgood tables as it only considers notgood or distincts answers, so the last try is not count
|
||||
if SubmissionUniqueness || CountOnlyNotGoodTries {
|
||||
DBQueryRow("SELECT MAX(time) FROM exercice_tries WHERE id_team = ? AND id_exercice = ?", t.Id, e.Id).Scan(&tm)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// LastTryDist retrieves the distance to the correct answers, for the given challenge.
|
||||
|
|
Loading…
Reference in New Issue