aboutsummaryrefslogtreecommitdiff
path: root/backend/controllers/recordController.go
diff options
context:
space:
mode:
authorNidboj132 <lol2s@vp.pl>2023-05-06 16:11:37 +0200
committerGitHub <noreply@github.com>2023-05-06 16:11:37 +0200
commitcbe16bdb713a5d82a7a67a4a2a4f1d49b59663ae (patch)
tree4d04c0cdea26e0e497134b99c0e34a7d9d478f34 /backend/controllers/recordController.go
parentlogin test (diff)
parentfix: allow credentials cors (diff)
downloadlphub-cbe16bdb713a5d82a7a67a4a2a4f1d49b59663ae.tar.gz
lphub-cbe16bdb713a5d82a7a67a4a2a4f1d49b59663ae.tar.bz2
lphub-cbe16bdb713a5d82a7a67a4a2a4f1d49b59663ae.zip
Merge branch 'pektezol:main' into main
Diffstat (limited to 'backend/controllers/recordController.go')
-rw-r--r--backend/controllers/recordController.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/backend/controllers/recordController.go b/backend/controllers/recordController.go
index bafa844..627be57 100644
--- a/backend/controllers/recordController.go
+++ b/backend/controllers/recordController.go
@@ -46,7 +46,7 @@ func CreateRecordWithDemo(c *gin.Context) {
46 var gameID int 46 var gameID int
47 var isCoop bool 47 var isCoop bool
48 var isDisabled bool 48 var isDisabled bool
49 sql := `SELECT game_id, is_disabled FROM maps WHERE id = $1;` 49 sql := `SELECT game_id, is_disabled FROM maps WHERE id = $1`
50 err := database.DB.QueryRow(sql, mapId).Scan(&gameID, &isDisabled) 50 err := database.DB.QueryRow(sql, mapId).Scan(&gameID, &isDisabled)
51 if err != nil { 51 if err != nil {
52 c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) 52 c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error()))
@@ -153,7 +153,7 @@ func CreateRecordWithDemo(c *gin.Context) {
153 // Insert into records 153 // Insert into records
154 if isCoop { 154 if isCoop {
155 sql := `INSERT INTO records_mp(map_id,score_count,score_time,host_id,partner_id,host_demo_id,partner_demo_id) 155 sql := `INSERT INTO records_mp(map_id,score_count,score_time,host_id,partner_id,host_demo_id,partner_demo_id)
156 VALUES($1, $2, $3, $4, $5, $6, $7);` 156 VALUES($1, $2, $3, $4, $5, $6, $7)`
157 var hostID string 157 var hostID string
158 var partnerID string 158 var partnerID string
159 if record.IsPartnerOrange { 159 if record.IsPartnerOrange {
@@ -171,7 +171,7 @@ func CreateRecordWithDemo(c *gin.Context) {
171 } 171 }
172 // If a new world record based on portal count 172 // If a new world record based on portal count
173 // if record.ScoreCount < wrScore { 173 // if record.ScoreCount < wrScore {
174 // _, err := tx.Exec(`UPDATE maps SET wr_score = $1, wr_time = $2 WHERE id = $3;`, record.ScoreCount, record.ScoreTime, mapId) 174 // _, err := tx.Exec(`UPDATE maps SET wr_score = $1, wr_time = $2 WHERE id = $3`, record.ScoreCount, record.ScoreTime, mapId)
175 // if err != nil { 175 // if err != nil {
176 // c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) 176 // c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error()))
177 // return 177 // return
@@ -179,7 +179,7 @@ func CreateRecordWithDemo(c *gin.Context) {
179 // } 179 // }
180 } else { 180 } else {
181 sql := `INSERT INTO records_sp(map_id,score_count,score_time,user_id,demo_id) 181 sql := `INSERT INTO records_sp(map_id,score_count,score_time,user_id,demo_id)
182 VALUES($1, $2, $3, $4, $5);` 182 VALUES($1, $2, $3, $4, $5)`
183 _, err := tx.Exec(sql, mapId, record.ScoreCount, record.ScoreTime, user.(models.User).SteamID, hostDemoUUID) 183 _, err := tx.Exec(sql, mapId, record.ScoreCount, record.ScoreTime, user.(models.User).SteamID, hostDemoUUID)
184 if err != nil { 184 if err != nil {
185 deleteFile(srv, fileID) 185 deleteFile(srv, fileID)
@@ -188,7 +188,7 @@ func CreateRecordWithDemo(c *gin.Context) {
188 } 188 }
189 // If a new world record based on portal count 189 // If a new world record based on portal count
190 // if record.ScoreCount < wrScore { 190 // if record.ScoreCount < wrScore {
191 // _, err := tx.Exec(`UPDATE maps SET wr_score = $1, wr_time = $2 WHERE id = $3;`, record.ScoreCount, record.ScoreTime, mapId) 191 // _, err := tx.Exec(`UPDATE maps SET wr_score = $1, wr_time = $2 WHERE id = $3`, record.ScoreCount, record.ScoreTime, mapId)
192 // if err != nil { 192 // if err != nil {
193 // c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) 193 // c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error()))
194 // return 194 // return
@@ -224,7 +224,7 @@ func DownloadDemoWithID(c *gin.Context) {
224 c.JSON(http.StatusBadRequest, models.ErrorResponse("Invalid id given.")) 224 c.JSON(http.StatusBadRequest, models.ErrorResponse("Invalid id given."))
225 return 225 return
226 } 226 }
227 err := database.DB.QueryRow(`SELECT location_id FROM demos WHERE id = $1;`, uuid).Scan(&locationID) 227 err := database.DB.QueryRow(`SELECT location_id FROM demos WHERE id = $1`, uuid).Scan(&locationID)
228 if err != nil { 228 if err != nil {
229 c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) 229 c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error()))
230 return 230 return