From 09e65803c96d6b89f3ce8d78c8c7b19580253b4b Mon Sep 17 00:00:00 2001 From: prokopparuzek Date: Thu, 6 Nov 2025 11:55:08 +0100 Subject: [PATCH] skip penalties check when already solved --- klice.go | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/klice.go b/klice.go index a35a68a..32a2bdf 100644 --- a/klice.go +++ b/klice.go @@ -231,18 +231,20 @@ func qrHandler(w http.ResponseWriter, r *http.Request) { } // get penalties for this task and team - err = db.QueryRow("SELECT minutes FROM penalties WHERE team_id = ? AND task_id = ?", teamID, taskID).Scan(&penalty) - if err == sql.ErrNoRows { - penalty = 0 - } else if err != nil { - http.Error(w, "Could not retrieve penalties", http.StatusInternalServerError) - return - } - // determine help level based on penalties - if penalty > 0 && penalty <= smallHelpPenalty { - help = 1 - } else if penalty > smallHelpPenalty { - help = 2 + if help == 0 { + err = db.QueryRow("SELECT minutes FROM penalties WHERE team_id = ? AND task_id = ?", teamID, taskID).Scan(&penalty) + if err == sql.ErrNoRows { + penalty = 0 + } else if err != nil { + http.Error(w, "Could not retrieve penalties", http.StatusInternalServerError) + return + } + // determine help level based on penalties + if penalty > 0 && penalty <= smallHelpPenalty { + help = 1 + } else if penalty > smallHelpPenalty { + help = 2 + } } // handle answer and help form submission