aboutsummaryrefslogtreecommitdiff
path: root/backend/handlers
diff options
context:
space:
mode:
authorArda Serdar Pektezol <1669855+pektezol@users.noreply.github.com>2023-09-28 02:08:55 +0300
committerGitHub <noreply@github.com>2023-09-28 02:08:55 +0300
commit7160f054819caa45a72170786d892640e4a5f922 (patch)
tree1f8081ec13181b97f1edb1934b6acae2e9405797 /backend/handlers
parentfix: 0 score count summaries give false binding required error (#104) (diff)
downloadlphub-7160f054819caa45a72170786d892640e4a5f922.tar.gz
lphub-7160f054819caa45a72170786d892640e4a5f922.tar.bz2
lphub-7160f054819caa45a72170786d892640e4a5f922.zip
fix: check for category id for map history when deleting summary (#106)
Former-commit-id: c79f58aaf4c174157d20b08a1c27ee9b9fcb305d
Diffstat (limited to 'backend/handlers')
-rw-r--r--backend/handlers/mod.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/backend/handlers/mod.go b/backend/handlers/mod.go
index f55784a..89e3618 100644
--- a/backend/handlers/mod.go
+++ b/backend/handlers/mod.go
@@ -248,9 +248,9 @@ func DeleteMapSummary(c *gin.Context) {
248 } 248 }
249 defer tx.Rollback() 249 defer tx.Rollback()
250 // Fetch route category and score count 250 // Fetch route category and score count
251 var checkMapID, scoreCount, mapHistoryID int 251 var checkMapID, scoreCount, categoryID, mapHistoryID int
252 sql := `SELECT m.id, mr.score_count FROM maps m INNER JOIN map_routes mr ON m.id=mr.map_id WHERE m.id = $1 AND mr.id = $2` 252 sql := `SELECT m.id, mr.score_count, mr.category_id FROM maps m INNER JOIN map_routes mr ON m.id=mr.map_id WHERE m.id = $1 AND mr.id = $2`
253 err = database.DB.QueryRow(sql, mapID, request.RouteID).Scan(&checkMapID, &scoreCount) 253 err = database.DB.QueryRow(sql, mapID, request.RouteID).Scan(&checkMapID, &scoreCount, &categoryID)
254 if err != nil { 254 if err != nil {
255 CreateLog(user.(models.User).SteamID, LogTypeMod, LogDescriptionMapSummaryDeleteFail, "S#map_routes: "+err.Error()) 255 CreateLog(user.(models.User).SteamID, LogTypeMod, LogDescriptionMapSummaryDeleteFail, "S#map_routes: "+err.Error())
256 c.JSON(http.StatusOK, models.ErrorResponse(err.Error())) 256 c.JSON(http.StatusOK, models.ErrorResponse(err.Error()))
@@ -260,8 +260,8 @@ func DeleteMapSummary(c *gin.Context) {
260 c.JSON(http.StatusOK, models.ErrorResponse("Map ID does not exist.")) 260 c.JSON(http.StatusOK, models.ErrorResponse("Map ID does not exist."))
261 return 261 return
262 } 262 }
263 sql = `SELECT mh.id FROM maps m INNER JOIN map_routes mr ON m.id=mr.map_id INNER JOIN map_history mh ON m.id=mh.map_id WHERE m.id = $1 AND mr.id = $2 AND mh.score_count = $3` 263 sql = `SELECT mh.id FROM maps m INNER JOIN map_routes mr ON m.id=mr.map_id INNER JOIN map_history mh ON m.id=mh.map_id WHERE m.id = $1 AND mh.category_id = $2 AND mh.score_count = $3`
264 err = database.DB.QueryRow(sql, mapID, request.RouteID, scoreCount).Scan(&mapHistoryID) 264 err = database.DB.QueryRow(sql, mapID, categoryID, scoreCount).Scan(&mapHistoryID)
265 if err != nil { 265 if err != nil {
266 CreateLog(user.(models.User).SteamID, LogTypeMod, LogDescriptionMapSummaryDeleteFail, "S#map_history: "+err.Error()) 266 CreateLog(user.(models.User).SteamID, LogTypeMod, LogDescriptionMapSummaryDeleteFail, "S#map_history: "+err.Error())
267 c.JSON(http.StatusOK, models.ErrorResponse(err.Error())) 267 c.JSON(http.StatusOK, models.ErrorResponse(err.Error()))