diff options
| author | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2023-01-15 03:28:07 +0300 |
|---|---|---|
| committer | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2023-01-15 03:28:07 +0300 |
| commit | 8b468651781e0f9ab57ae79810f506f5accbd596 (patch) | |
| tree | dbf0fd67b499493c85f0e5e88882a69fde77a2cc | |
| parent | add wr time to maps database (diff) | |
| download | lphub-8b468651781e0f9ab57ae79810f506f5accbd596.tar.gz lphub-8b468651781e0f9ab57ae79810f506f5accbd596.tar.bz2 lphub-8b468651781e0f9ab57ae79810f506f5accbd596.zip | |
check if map is disabled or not
| -rw-r--r-- | backend/controllers/recordController.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/backend/controllers/recordController.go b/backend/controllers/recordController.go index c60827a..b212e1f 100644 --- a/backend/controllers/recordController.go +++ b/backend/controllers/recordController.go | |||
| @@ -28,13 +28,18 @@ func CreateRecordWithDemo(c *gin.Context) { | |||
| 28 | } | 28 | } |
| 29 | // Check if map is sp or mp | 29 | // Check if map is sp or mp |
| 30 | var isCoop bool | 30 | var isCoop bool |
| 31 | err := database.DB.QueryRow(`SELECT is_coop FROM maps WHERE id = $1;`, mapId).Scan(&isCoop) | 31 | var isDisabled bool |
| 32 | err := database.DB.QueryRow(`SELECT is_coop, is_disabled FROM maps WHERE id = $1;`, mapId).Scan(&isCoop, &isDisabled) | ||
| 32 | if err != nil { | 33 | if err != nil { |
| 33 | c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) | 34 | c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) |
| 34 | return | 35 | return |
| 35 | } | 36 | } |
| 37 | if isDisabled { | ||
| 38 | c.JSON(http.StatusBadRequest, models.ErrorResponse("Map is not available for competitive boards.")) | ||
| 39 | return | ||
| 40 | } | ||
| 36 | // Get record request | 41 | // Get record request |
| 37 | var record models.Record | 42 | var record models.RecordRequest |
| 38 | score_count, err := strconv.Atoi(c.PostForm("score_count")) | 43 | score_count, err := strconv.Atoi(c.PostForm("score_count")) |
| 39 | if err != nil { | 44 | if err != nil { |
| 40 | c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) | 45 | c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) |