From 85c6da965ec401dabb162df09160b4ce9dc28413 Mon Sep 17 00:00:00 2001 From: Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> Date: Thu, 29 Jun 2023 11:57:53 +0300 Subject: feat: route id in map summary, update docs Former-commit-id: f8db004d2c17f09f665e51ec4e730418248bfd07 --- backend/controllers/mapController.go | 4 ++-- backend/controllers/modController.go | 7 ++++--- backend/controllers/recordController.go | 5 ++--- backend/models/models.go | 1 + 4 files changed, 9 insertions(+), 8 deletions(-) (limited to 'backend') diff --git a/backend/controllers/mapController.go b/backend/controllers/mapController.go index 77f8e10..7dfd2be 100644 --- a/backend/controllers/mapController.go +++ b/backend/controllers/mapController.go @@ -39,7 +39,7 @@ func FetchMapSummary(c *gin.Context) { return } // Get map routes and histories - sql = `SELECT c.id, c.name, h.user_name, h.score_count, h.record_date, r.description, r.showcase, COALESCE(avg(rating), 0.0) FROM map_routes r + sql = `SELECT r.id, c.id, c.name, h.user_name, h.score_count, h.record_date, r.description, r.showcase, COALESCE(avg(rating), 0.0) FROM map_routes r INNER JOIN categories c ON r.category_id = c.id INNER JOIN map_history h ON r.map_id = h.map_id AND r.category_id = h.category_id LEFT JOIN map_ratings rt ON r.map_id = rt.map_id AND r.category_id = rt.category_id @@ -52,7 +52,7 @@ func FetchMapSummary(c *gin.Context) { } for rows.Next() { route := models.MapRoute{Category: models.Category{}, History: models.MapHistory{}} - err = rows.Scan(&route.Category.ID, &route.Category.Name, &route.History.RunnerName, &route.History.ScoreCount, &route.History.Date, &route.Description, &route.Showcase, &route.Rating) + err = rows.Scan(&route.RouteID, &route.Category.ID, &route.Category.Name, &route.History.RunnerName, &route.History.ScoreCount, &route.History.Date, &route.Description, &route.Showcase, &route.Rating) if err != nil { c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) return diff --git a/backend/controllers/modController.go b/backend/controllers/modController.go index ebf1cb7..9d14f92 100644 --- a/backend/controllers/modController.go +++ b/backend/controllers/modController.go @@ -14,9 +14,10 @@ import ( // @Summary Edit map summary with specified map id. // @Tags maps // @Produce json -// @Param id path int true "Map ID" -// @Success 200 {object} models.Response{data=models.EditMapSummaryRequest} -// @Failure 400 {object} models.Response +// @Param id path int true "Map ID" +// @Param request body models.EditMapSummaryRequest true "Body" +// @Success 200 {object} models.Response{data=models.EditMapSummaryRequest} +// @Failure 400 {object} models.Response // @Router /maps/{id}/summary [put] func EditMapSummary(c *gin.Context) { // Check if user exists diff --git a/backend/controllers/recordController.go b/backend/controllers/recordController.go index aec31bb..c865bfb 100644 --- a/backend/controllers/recordController.go +++ b/backend/controllers/recordController.go @@ -30,7 +30,7 @@ import ( // @Param partner_demo formData file true "Partner Demo" // @Param is_partner_orange formData boolean true "Is Partner Orange" // @Param partner_id formData string true "Partner ID" -// @Success 200 {object} models.Response{data=models.RecordRequest} +// @Success 200 {object} models.Response // @Failure 400 {object} models.Response // @Failure 401 {object} models.Response // @Router /maps/{id}/record [post] @@ -179,9 +179,8 @@ func CreateRecordWithDemo(c *gin.Context) { c.JSON(http.StatusOK, models.Response{ Success: true, Message: "Successfully created record.", - Data: record, + Data: nil, }) - return } // GET Demo diff --git a/backend/models/models.go b/backend/models/models.go index 5355a9f..2524935 100644 --- a/backend/models/models.go +++ b/backend/models/models.go @@ -43,6 +43,7 @@ type MapHistory struct { } type MapRoute struct { + RouteID int `json:"route_id"` Category Category `json:"category"` History MapHistory `json:"history"` Rating float32 `json:"rating"` -- cgit v1.2.3