aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArda Serdar Pektezol <1669855+pektezol@users.noreply.github.com>2023-06-29 11:57:53 +0300
committerArda Serdar Pektezol <1669855+pektezol@users.noreply.github.com>2023-06-29 11:57:53 +0300
commit85c6da965ec401dabb162df09160b4ce9dc28413 (patch)
treebc62d79f948d8264b1a95c9d360883f5e8d7fc83
parentfix: auth sql typo (diff)
downloadlphub-85c6da965ec401dabb162df09160b4ce9dc28413.tar.gz
lphub-85c6da965ec401dabb162df09160b4ce9dc28413.tar.bz2
lphub-85c6da965ec401dabb162df09160b4ce9dc28413.zip
feat: route id in map summary, update docs
Former-commit-id: f8db004d2c17f09f665e51ec4e730418248bfd07
-rw-r--r--backend/controllers/mapController.go4
-rw-r--r--backend/controllers/modController.go7
-rw-r--r--backend/controllers/recordController.go5
-rw-r--r--backend/models/models.go1
-rw-r--r--docs/docs.go9
-rw-r--r--docs/swagger.json9
-rw-r--r--docs/swagger.yaml6
7 files changed, 33 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]
21func EditMapSummary(c *gin.Context) { 22func 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
45type MapRoute struct { 45type 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"`
diff --git a/docs/docs.go b/docs/docs.go
index 090d3e8..91f91ef 100644
--- a/docs/docs.go
+++ b/docs/docs.go
@@ -467,6 +467,15 @@ const docTemplate = `{
467 "name": "id", 467 "name": "id",
468 "in": "path", 468 "in": "path",
469 "required": true 469 "required": true
470 },
471 {
472 "description": "Body",
473 "name": "request",
474 "in": "body",
475 "required": true,
476 "schema": {
477 "$ref": "#/definitions/models.EditMapSummaryRequest"
478 }
470 } 479 }
471 ], 480 ],
472 "responses": { 481 "responses": {
diff --git a/docs/swagger.json b/docs/swagger.json
index 62079b1..c6bbfbc 100644
--- a/docs/swagger.json
+++ b/docs/swagger.json
@@ -460,6 +460,15 @@
460 "name": "id", 460 "name": "id",
461 "in": "path", 461 "in": "path",
462 "required": true 462 "required": true
463 },
464 {
465 "description": "Body",
466 "name": "request",
467 "in": "body",
468 "required": true,
469 "schema": {
470 "$ref": "#/definitions/models.EditMapSummaryRequest"
471 }
463 } 472 }
464 ], 473 ],
465 "responses": { 474 "responses": {
diff --git a/docs/swagger.yaml b/docs/swagger.yaml
index 9d58620..4291cfc 100644
--- a/docs/swagger.yaml
+++ b/docs/swagger.yaml
@@ -480,6 +480,12 @@ paths:
480 name: id 480 name: id
481 required: true 481 required: true
482 type: integer 482 type: integer
483 - description: Body
484 in: body
485 name: request
486 required: true
487 schema:
488 $ref: '#/definitions/models.EditMapSummaryRequest'
483 produces: 489 produces:
484 - application/json 490 - application/json
485 responses: 491 responses: