Fixed error caused by canceling the SQL statement before it is used

This commit is contained in:
2023-07-21 18:37:40 +01:00
parent 5d2aba9caa
commit 6ad1e9aa5c
2 changed files with 2 additions and 4 deletions

BIN
main

Binary file not shown.

View File

@@ -151,22 +151,20 @@ func getHistory(c *gin.Context) {
var tempUser loginOutput
stmt, err := db.Prepare("SELECT * FROM users WHERE uid=?")
checkErr(err)
err = stmt.Close()
checkErr(err)
err = stmt.QueryRow(history[i].UID).Scan(&tempUser.UID, &tempUser.Name, &tempUser.Password, &tempUser.Role)
checkErr(err)
tempHistory.User = tempUser.Name
stmt.Close()
// get the task name and points
var tempTask task
stmt, err = db.Prepare("SELECT * FROM activities WHERE taskId=?")
checkErr(err)
err = stmt.Close()
checkErr(err)
err = stmt.QueryRow(history[i].TID).Scan(&tempTask.TID, &tempTask.Name, &tempTask.Points)
checkErr(err)
tempHistory.Task = tempTask.Name
tempHistory.PointsGained = tempTask.Points
stmt.Close()
tempHistory.Time = history[i].Time