aboutsummaryrefslogtreecommitdiff
path: root/backend/controllers/mapController.go
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--backend/controllers/mapController.go22
1 files changed, 11 insertions, 11 deletions
diff --git a/backend/controllers/mapController.go b/backend/controllers/mapController.go
index 506daa2..d8783b7 100644
--- a/backend/controllers/mapController.go
+++ b/backend/controllers/mapController.go
@@ -56,7 +56,7 @@ func FetchMapSummary(c *gin.Context) {
56 FROM maps m 56 FROM maps m
57 INNER JOIN games g ON m.game_id = g.id 57 INNER JOIN games g ON m.game_id = g.id
58 INNER JOIN chapters c ON m.chapter_id = c.id 58 INNER JOIN chapters c ON m.chapter_id = c.id
59 WHERE m.id = $1;` 59 WHERE m.id = $1`
60 // TODO: CategoryScores 60 // TODO: CategoryScores
61 err = database.DB.QueryRow(sql, id).Scan(&mapData.GameName, &mapData.ChapterName, &mapData.MapName, &mapSummaryData.Description, &mapSummaryData.Showcase, &routers, &mapSummaryData.Rating) 61 err = database.DB.QueryRow(sql, id).Scan(&mapData.GameName, &mapData.ChapterName, &mapData.MapName, &mapSummaryData.Description, &mapSummaryData.Showcase, &routers, &mapSummaryData.Rating)
62 if err != nil { 62 if err != nil {
@@ -68,7 +68,7 @@ func FetchMapSummary(c *gin.Context) {
68 var historyDates pq.StringArray 68 var historyDates pq.StringArray
69 sql = `SELECT array_agg(user_name), array_agg(score_count), array_agg(record_date) 69 sql = `SELECT array_agg(user_name), array_agg(score_count), array_agg(record_date)
70 FROM map_history 70 FROM map_history
71 WHERE map_id = $1;` 71 WHERE map_id = $1`
72 err = database.DB.QueryRow(sql, id).Scan(&historyNames, &historyScores, &historyDates) 72 err = database.DB.QueryRow(sql, id).Scan(&historyNames, &historyScores, &historyDates)
73 if err != nil { 73 if err != nil {
74 c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) 74 c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error()))
@@ -123,7 +123,7 @@ func FetchMapLeaderboards(c *gin.Context) {
123 FROM maps m 123 FROM maps m
124 INNER JOIN games g ON m.game_id = g.id 124 INNER JOIN games g ON m.game_id = g.id
125 INNER JOIN chapters c ON m.chapter_id = c.id 125 INNER JOIN chapters c ON m.chapter_id = c.id
126 WHERE m.id = $1;` 126 WHERE m.id = $1`
127 err = database.DB.QueryRow(sql, id).Scan(&mapData.GameName, &mapData.ChapterName, &mapData.MapName, &isDisabled) 127 err = database.DB.QueryRow(sql, id).Scan(&mapData.GameName, &mapData.ChapterName, &mapData.MapName, &isDisabled)
128 if err != nil { 128 if err != nil {
129 c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) 129 c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error()))
@@ -144,7 +144,7 @@ func FetchMapLeaderboards(c *gin.Context) {
144 FROM records_mp 144 FROM records_mp
145 WHERE map_id = $1 145 WHERE map_id = $1
146 ) sub 146 ) sub
147 WHERE rn = 1;` 147 WHERE rn = 1`
148 rows, err := database.DB.Query(sql, id) 148 rows, err := database.DB.Query(sql, id)
149 if err != nil { 149 if err != nil {
150 c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) 150 c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error()))
@@ -179,7 +179,7 @@ func FetchMapLeaderboards(c *gin.Context) {
179 WHERE map_id = $1 179 WHERE map_id = $1
180 ) sub 180 ) sub
181 INNER JOIN users ON user_id = users.steam_id 181 INNER JOIN users ON user_id = users.steam_id
182 WHERE rn = 1;` 182 WHERE rn = 1`
183 rows, err := database.DB.Query(sql, id) 183 rows, err := database.DB.Query(sql, id)
184 if err != nil { 184 if err != nil {
185 c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) 185 c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error()))
@@ -217,7 +217,7 @@ func FetchMapLeaderboards(c *gin.Context) {
217// GET Games 217// GET Games
218// 218//
219// @Summary Get games from the leaderboards. 219// @Summary Get games from the leaderboards.
220// @Tags games 220// @Tags games & chapters
221// @Produce json 221// @Produce json
222// @Success 200 {object} models.Response{data=[]models.Game} 222// @Success 200 {object} models.Response{data=[]models.Game}
223// @Failure 400 {object} models.Response 223// @Failure 400 {object} models.Response
@@ -247,12 +247,12 @@ func FetchGames(c *gin.Context) {
247// GET Chapters of a Game 247// GET Chapters of a Game
248// 248//
249// @Summary Get chapters from the specified game id. 249// @Summary Get chapters from the specified game id.
250// @Tags chapters 250// @Tags games & chapters
251// @Produce json 251// @Produce json
252// @Param id path int true "Game ID" 252// @Param id path int true "Game ID"
253// @Success 200 {object} models.Response{data=models.ChaptersResponse} 253// @Success 200 {object} models.Response{data=models.ChaptersResponse}
254// @Failure 400 {object} models.Response 254// @Failure 400 {object} models.Response
255// @Router /chapters/{id} [get] 255// @Router /games/{id} [get]
256func FetchChapters(c *gin.Context) { 256func FetchChapters(c *gin.Context) {
257 gameID := c.Param("id") 257 gameID := c.Param("id")
258 intID, err := strconv.Atoi(gameID) 258 intID, err := strconv.Atoi(gameID)
@@ -289,12 +289,12 @@ func FetchChapters(c *gin.Context) {
289// GET Maps of a Chapter 289// GET Maps of a Chapter
290// 290//
291// @Summary Get maps from the specified chapter id. 291// @Summary Get maps from the specified chapter id.
292// @Tags maps 292// @Tags games & chapters
293// @Produce json 293// @Produce json
294// @Param id path int true "Chapter ID" 294// @Param id path int true "Chapter ID"
295// @Success 200 {object} models.Response{data=[]models.MapShort} 295// @Success 200 {object} models.Response{data=models.ChapterMapsResponse}
296// @Failure 400 {object} models.Response 296// @Failure 400 {object} models.Response
297// @Router /maps/{id} [get] 297// @Router /chapters/{id} [get]
298func FetchChapterMaps(c *gin.Context) { 298func FetchChapterMaps(c *gin.Context) {
299 chapterID := c.Param("id") 299 chapterID := c.Param("id")
300 intID, err := strconv.Atoi(chapterID) 300 intID, err := strconv.Atoi(chapterID)