diff options
| author | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2023-06-29 11:57:53 +0300 |
|---|---|---|
| committer | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2023-06-29 11:57:53 +0300 |
| commit | 85c6da965ec401dabb162df09160b4ce9dc28413 (patch) | |
| tree | bc62d79f948d8264b1a95c9d360883f5e8d7fc83 /backend | |
| parent | fix: auth sql typo (diff) | |
| download | lphub-85c6da965ec401dabb162df09160b4ce9dc28413.tar.gz lphub-85c6da965ec401dabb162df09160b4ce9dc28413.tar.bz2 lphub-85c6da965ec401dabb162df09160b4ce9dc28413.zip | |
feat: route id in map summary, update docs
Former-commit-id: f8db004d2c17f09f665e51ec4e730418248bfd07
Diffstat (limited to 'backend')
| -rw-r--r-- | backend/controllers/mapController.go | 4 | ||||
| -rw-r--r-- | backend/controllers/modController.go | 7 | ||||
| -rw-r--r-- | backend/controllers/recordController.go | 5 | ||||
| -rw-r--r-- | backend/models/models.go | 1 |
4 files changed, 9 insertions, 8 deletions
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) { | |||
| 39 | return | 39 | return |
| 40 | } | 40 | } |
| 41 | // Get map routes and histories | 41 | // Get map routes and histories |
| 42 | 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 | 42 | 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 |
| 43 | INNER JOIN categories c ON r.category_id = c.id | 43 | INNER JOIN categories c ON r.category_id = c.id |
| 44 | INNER JOIN map_history h ON r.map_id = h.map_id AND r.category_id = h.category_id | 44 | INNER JOIN map_history h ON r.map_id = h.map_id AND r.category_id = h.category_id |
| 45 | LEFT JOIN map_ratings rt ON r.map_id = rt.map_id AND r.category_id = rt.category_id | 45 | 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) { | |||
| 52 | } | 52 | } |
| 53 | for rows.Next() { | 53 | for rows.Next() { |
| 54 | route := models.MapRoute{Category: models.Category{}, History: models.MapHistory{}} | 54 | route := models.MapRoute{Category: models.Category{}, History: models.MapHistory{}} |
| 55 | err = rows.Scan(&route.Category.ID, &route.Category.Name, &route.History.RunnerName, &route.History.ScoreCount, &route.History.Date, &route.Description, &route.Showcase, &route.Rating) | 55 | 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) |
| 56 | if err != nil { | 56 | if err != nil { |
| 57 | c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) | 57 | c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) |
| 58 | return | 58 | 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 ( | |||
| 14 | // @Summary Edit map summary with specified map id. | 14 | // @Summary Edit map summary with specified map id. |
| 15 | // @Tags maps | 15 | // @Tags maps |
| 16 | // @Produce json | 16 | // @Produce json |
| 17 | // @Param id path int true "Map ID" | 17 | // @Param id path int true "Map ID" |
| 18 | // @Success 200 {object} models.Response{data=models.EditMapSummaryRequest} | 18 | // @Param request body models.EditMapSummaryRequest true "Body" |
| 19 | // @Failure 400 {object} models.Response | 19 | // @Success 200 {object} models.Response{data=models.EditMapSummaryRequest} |
| 20 | // @Failure 400 {object} models.Response | ||
| 20 | // @Router /maps/{id}/summary [put] | 21 | // @Router /maps/{id}/summary [put] |
| 21 | func EditMapSummary(c *gin.Context) { | 22 | func EditMapSummary(c *gin.Context) { |
| 22 | // Check if user exists | 23 | // 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 ( | |||
| 30 | // @Param partner_demo formData file true "Partner Demo" | 30 | // @Param partner_demo formData file true "Partner Demo" |
| 31 | // @Param is_partner_orange formData boolean true "Is Partner Orange" | 31 | // @Param is_partner_orange formData boolean true "Is Partner Orange" |
| 32 | // @Param partner_id formData string true "Partner ID" | 32 | // @Param partner_id formData string true "Partner ID" |
| 33 | // @Success 200 {object} models.Response{data=models.RecordRequest} | 33 | // @Success 200 {object} models.Response |
| 34 | // @Failure 400 {object} models.Response | 34 | // @Failure 400 {object} models.Response |
| 35 | // @Failure 401 {object} models.Response | 35 | // @Failure 401 {object} models.Response |
| 36 | // @Router /maps/{id}/record [post] | 36 | // @Router /maps/{id}/record [post] |
| @@ -179,9 +179,8 @@ func CreateRecordWithDemo(c *gin.Context) { | |||
| 179 | c.JSON(http.StatusOK, models.Response{ | 179 | c.JSON(http.StatusOK, models.Response{ |
| 180 | Success: true, | 180 | Success: true, |
| 181 | Message: "Successfully created record.", | 181 | Message: "Successfully created record.", |
| 182 | Data: record, | 182 | Data: nil, |
| 183 | }) | 183 | }) |
| 184 | return | ||
| 185 | } | 184 | } |
| 186 | 185 | ||
| 187 | // GET Demo | 186 | // 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 { | |||
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | type MapRoute struct { | 45 | type MapRoute struct { |
| 46 | RouteID int `json:"route_id"` | ||
| 46 | Category Category `json:"category"` | 47 | Category Category `json:"category"` |
| 47 | History MapHistory `json:"history"` | 48 | History MapHistory `json:"history"` |
| 48 | Rating float32 `json:"rating"` | 49 | Rating float32 `json:"rating"` |