diff options
| -rw-r--r-- | backend/controllers/mapController.go | 79 | ||||
| -rw-r--r-- | backend/models/models.go | 37 | ||||
| -rw-r--r-- | backend/models/responses.go | 5 | ||||
| -rw-r--r-- | docs/docs.go | 127 | ||||
| -rw-r--r-- | docs/swagger.json | 127 | ||||
| -rw-r--r-- | docs/swagger.yaml | 82 |
6 files changed, 207 insertions, 250 deletions
diff --git a/backend/controllers/mapController.go b/backend/controllers/mapController.go index d8783b7..37b8e9b 100644 --- a/backend/controllers/mapController.go +++ b/backend/controllers/mapController.go | |||
| @@ -3,10 +3,8 @@ package controllers | |||
| 3 | import ( | 3 | import ( |
| 4 | "net/http" | 4 | "net/http" |
| 5 | "strconv" | 5 | "strconv" |
| 6 | "time" | ||
| 7 | 6 | ||
| 8 | "github.com/gin-gonic/gin" | 7 | "github.com/gin-gonic/gin" |
| 9 | "github.com/lib/pq" | ||
| 10 | "github.com/pektezol/leastportals/backend/database" | 8 | "github.com/pektezol/leastportals/backend/database" |
| 11 | "github.com/pektezol/leastportals/backend/models" | 9 | "github.com/pektezol/leastportals/backend/models" |
| 12 | ) | 10 | ) |
| @@ -17,37 +15,20 @@ import ( | |||
| 17 | // @Tags maps | 15 | // @Tags maps |
| 18 | // @Produce json | 16 | // @Produce json |
| 19 | // @Param id path int true "Map ID" | 17 | // @Param id path int true "Map ID" |
| 20 | // @Success 200 {object} models.Response{data=models.Map{data=models.MapSummary}} | 18 | // @Success 200 {object} models.Response{data=models.MapSummaryResponse} |
| 21 | // @Failure 400 {object} models.Response | 19 | // @Failure 400 {object} models.Response |
| 22 | // @Router /maps/{id}/summary [get] | 20 | // @Router /maps/{id}/summary [get] |
| 23 | func FetchMapSummary(c *gin.Context) { | 21 | func FetchMapSummary(c *gin.Context) { |
| 24 | id := c.Param("id") | 22 | id := c.Param("id") |
| 25 | // Get map data | 23 | // Get map data |
| 26 | var mapData models.Map | 24 | response := models.MapSummaryResponse{Map: models.Map{}, Summary: models.MapSummary{History: []models.MapHistory{}, Routes: []models.MapRoute{}}} |
| 27 | var mapSummaryData models.MapSummary | ||
| 28 | var mapHistoryData []models.MapHistory | ||
| 29 | intID, err := strconv.Atoi(id) | 25 | intID, err := strconv.Atoi(id) |
| 30 | if err != nil { | 26 | if err != nil { |
| 31 | c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) | 27 | c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) |
| 32 | return | 28 | return |
| 33 | } | 29 | } |
| 34 | mapData.ID = intID | 30 | response.Map.ID = intID |
| 35 | var routers pq.StringArray | 31 | sql := `SELECT m.id, g.name, c.name, m.name, |
| 36 | sql := `SELECT g.name, c.name, m.name, m.description, m.showcase, | ||
| 37 | ( | ||
| 38 | SELECT array_agg(user_name) | ||
| 39 | FROM map_routers | ||
| 40 | WHERE map_id = $1 | ||
| 41 | AND score_count = ( | ||
| 42 | SELECT score_count | ||
| 43 | FROM map_history | ||
| 44 | WHERE map_id = $1 | ||
| 45 | ORDER BY score_count | ||
| 46 | LIMIT 1 | ||
| 47 | ) | ||
| 48 | GROUP BY map_routers.user_name | ||
| 49 | ORDER BY user_name | ||
| 50 | ), | ||
| 51 | ( | 32 | ( |
| 52 | SELECT COALESCE(avg(rating), 0.0) | 33 | SELECT COALESCE(avg(rating), 0.0) |
| 53 | FROM map_ratings | 34 | FROM map_ratings |
| @@ -57,44 +38,53 @@ func FetchMapSummary(c *gin.Context) { | |||
| 57 | INNER JOIN games g ON m.game_id = g.id | 38 | INNER JOIN games g ON m.game_id = g.id |
| 58 | INNER JOIN chapters c ON m.chapter_id = c.id | 39 | INNER JOIN chapters c ON m.chapter_id = c.id |
| 59 | WHERE m.id = $1` | 40 | WHERE m.id = $1` |
| 60 | // TODO: CategoryScores | 41 | err = database.DB.QueryRow(sql, id).Scan(&response.Map.ID, &response.Map.GameName, &response.Map.ChapterName, &response.Map.MapName, &response.Summary.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 { | 42 | if err != nil { |
| 63 | c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) | 43 | c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) |
| 64 | return | 44 | return |
| 65 | } | 45 | } |
| 66 | var historyNames pq.StringArray | 46 | sql = `SELECT user_name, score_count, record_date |
| 67 | var historyScores pq.Int32Array | ||
| 68 | var historyDates pq.StringArray | ||
| 69 | sql = `SELECT array_agg(user_name), array_agg(score_count), array_agg(record_date) | ||
| 70 | FROM map_history | 47 | FROM map_history |
| 71 | WHERE map_id = $1` | 48 | WHERE map_id = $1 |
| 72 | err = database.DB.QueryRow(sql, id).Scan(&historyNames, &historyScores, &historyDates) | 49 | ORDER BY record_date ASC` |
| 50 | rows, err := database.DB.Query(sql, id) | ||
| 51 | if err != nil { | ||
| 52 | c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) | ||
| 53 | return | ||
| 54 | } | ||
| 55 | for rows.Next() { | ||
| 56 | history := models.MapHistory{} | ||
| 57 | err = rows.Scan(&history.RunnerName, &history.ScoreCount, &history.Date) | ||
| 58 | if err != nil { | ||
| 59 | c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) | ||
| 60 | return | ||
| 61 | } | ||
| 62 | response.Summary.History = append(response.Summary.History, history) | ||
| 63 | } | ||
| 64 | sql = `SELECT c.id, c.name, mr.score_count, mr.description, mr.showcase | ||
| 65 | FROM map_routes mr | ||
| 66 | INNER JOIN categories c ON mr.category_id = c.id | ||
| 67 | WHERE mr.map_id = $1 | ||
| 68 | ORDER BY mr.score_count DESC` | ||
| 69 | rows, err = database.DB.Query(sql, id) | ||
| 73 | if err != nil { | 70 | if err != nil { |
| 74 | c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) | 71 | c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) |
| 75 | return | 72 | return |
| 76 | } | 73 | } |
| 77 | for i := 0; i < len(historyNames); i++ { | 74 | for rows.Next() { |
| 78 | var history models.MapHistory | 75 | route := models.MapRoute{} |
| 79 | history.RunnerName = historyNames[i] | 76 | err = rows.Scan(&route.Category.ID, &route.Category.Name, &route.ScoreCount, &route.Description, &route.Showcase) |
| 80 | history.ScoreCount = int(historyScores[i]) | ||
| 81 | layout := "2006-01-02 15:04:05" | ||
| 82 | date, err := time.Parse(layout, historyDates[i]) | ||
| 83 | if err != nil { | 77 | if err != nil { |
| 84 | c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) | 78 | c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) |
| 85 | return | 79 | return |
| 86 | } | 80 | } |
| 87 | history.Date = date | 81 | response.Summary.Routes = append(response.Summary.Routes, route) |
| 88 | mapHistoryData = append(mapHistoryData, history) | ||
| 89 | } | 82 | } |
| 90 | mapSummaryData.History = mapHistoryData | ||
| 91 | mapSummaryData.Routers = routers | ||
| 92 | mapData.Data = mapSummaryData | ||
| 93 | // Return response | 83 | // Return response |
| 94 | c.JSON(http.StatusOK, models.Response{ | 84 | c.JSON(http.StatusOK, models.Response{ |
| 95 | Success: true, | 85 | Success: true, |
| 96 | Message: "Successfully retrieved map summary.", | 86 | Message: "Successfully retrieved map summary.", |
| 97 | Data: mapData, | 87 | Data: response, |
| 98 | }) | 88 | }) |
| 99 | } | 89 | } |
| 100 | 90 | ||
| @@ -108,6 +98,7 @@ func FetchMapSummary(c *gin.Context) { | |||
| 108 | // @Failure 400 {object} models.Response | 98 | // @Failure 400 {object} models.Response |
| 109 | // @Router /maps/{id}/leaderboards [get] | 99 | // @Router /maps/{id}/leaderboards [get] |
| 110 | func FetchMapLeaderboards(c *gin.Context) { | 100 | func FetchMapLeaderboards(c *gin.Context) { |
| 101 | // TODO: make new response type | ||
| 111 | id := c.Param("id") | 102 | id := c.Param("id") |
| 112 | // Get map data | 103 | // Get map data |
| 113 | var mapData models.Map | 104 | var mapData models.Map |
| @@ -205,7 +196,7 @@ func FetchMapLeaderboards(c *gin.Context) { | |||
| 205 | } | 196 | } |
| 206 | mapRecordsData.Records = records | 197 | mapRecordsData.Records = records |
| 207 | } | 198 | } |
| 208 | mapData.Data = mapRecordsData | 199 | // mapData.Data = mapRecordsData |
| 209 | // Return response | 200 | // Return response |
| 210 | c.JSON(http.StatusOK, models.Response{ | 201 | c.JSON(http.StatusOK, models.Response{ |
| 211 | Success: true, | 202 | Success: true, |
diff --git a/backend/models/models.go b/backend/models/models.go index 49a4f82..5c9b8f8 100644 --- a/backend/models/models.go +++ b/backend/models/models.go | |||
| @@ -23,7 +23,6 @@ type Map struct { | |||
| 23 | GameName string `json:"game_name"` | 23 | GameName string `json:"game_name"` |
| 24 | ChapterName string `json:"chapter_name"` | 24 | ChapterName string `json:"chapter_name"` |
| 25 | MapName string `json:"map_name"` | 25 | MapName string `json:"map_name"` |
| 26 | Data any `json:"data"` | ||
| 27 | } | 26 | } |
| 28 | 27 | ||
| 29 | type MapShort struct { | 28 | type MapShort struct { |
| @@ -32,23 +31,9 @@ type MapShort struct { | |||
| 32 | } | 31 | } |
| 33 | 32 | ||
| 34 | type MapSummary struct { | 33 | type MapSummary struct { |
| 35 | Description string `json:"description"` | 34 | Rating float32 `json:"rating"` |
| 36 | Showcase string `json:"showcase"` | 35 | History []MapHistory `json:"history"` |
| 37 | CategoryScores MapCategoryScores `json:"category_scores"` | 36 | Routes []MapRoute `json:"routes"` |
| 38 | Rating float32 `json:"rating"` | ||
| 39 | Routers []string `json:"routers"` | ||
| 40 | History []MapHistory `json:"history"` | ||
| 41 | } | ||
| 42 | |||
| 43 | type MapCategoryScores struct { | ||
| 44 | CM int `json:"cm"` | ||
| 45 | NoSLA int `json:"no_sla"` | ||
| 46 | InboundsSLA int `json:"inbounds_sla"` | ||
| 47 | Any int `json:"any"` | ||
| 48 | } | ||
| 49 | |||
| 50 | type MapRecords struct { | ||
| 51 | Records any `json:"records"` | ||
| 52 | } | 37 | } |
| 53 | 38 | ||
| 54 | type MapHistory struct { | 39 | type MapHistory struct { |
| @@ -57,6 +42,17 @@ type MapHistory struct { | |||
| 57 | Date time.Time `json:"date"` | 42 | Date time.Time `json:"date"` |
| 58 | } | 43 | } |
| 59 | 44 | ||
| 45 | type MapRoute struct { | ||
| 46 | Category Category `json:"category"` | ||
| 47 | ScoreCount int `json:"score_count"` | ||
| 48 | Description string `json:"description"` | ||
| 49 | Showcase string `json:"showcase"` | ||
| 50 | } | ||
| 51 | |||
| 52 | type MapRecords struct { | ||
| 53 | Records any `json:"records"` | ||
| 54 | } | ||
| 55 | |||
| 60 | type UserRanking struct { | 56 | type UserRanking struct { |
| 61 | UserID string `json:"user_id"` | 57 | UserID string `json:"user_id"` |
| 62 | UserName string `json:"user_name"` | 58 | UserName string `json:"user_name"` |
| @@ -73,6 +69,11 @@ type Chapter struct { | |||
| 73 | Name string `json:"name"` | 69 | Name string `json:"name"` |
| 74 | } | 70 | } |
| 75 | 71 | ||
| 72 | type Category struct { | ||
| 73 | ID int `json:"id"` | ||
| 74 | Name string `json:"name"` | ||
| 75 | } | ||
| 76 | |||
| 76 | type RecordSP struct { | 77 | type RecordSP struct { |
| 77 | RecordID int `json:"record_id"` | 78 | RecordID int `json:"record_id"` |
| 78 | Placement int `json:"placement"` | 79 | Placement int `json:"placement"` |
diff --git a/backend/models/responses.go b/backend/models/responses.go index 5a88353..dc554ff 100644 --- a/backend/models/responses.go +++ b/backend/models/responses.go | |||
| @@ -30,6 +30,11 @@ type ScoreResponse struct { | |||
| 30 | Records any `json:"records"` | 30 | Records any `json:"records"` |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | type MapSummaryResponse struct { | ||
| 34 | Map Map `json:"map"` | ||
| 35 | Summary MapSummary `json:"summary"` | ||
| 36 | } | ||
| 37 | |||
| 33 | type SearchResponse struct { | 38 | type SearchResponse struct { |
| 34 | Players []UserShort `json:"players"` | 39 | Players []UserShort `json:"players"` |
| 35 | Maps []MapShort `json:"maps"` | 40 | Maps []MapShort `json:"maps"` |
diff --git a/docs/docs.go b/docs/docs.go index 34aa7f4..cf6c00d 100644 --- a/docs/docs.go +++ b/docs/docs.go | |||
| @@ -447,19 +447,7 @@ const docTemplate = `{ | |||
| 447 | "type": "object", | 447 | "type": "object", |
| 448 | "properties": { | 448 | "properties": { |
| 449 | "data": { | 449 | "data": { |
| 450 | "allOf": [ | 450 | "$ref": "#/definitions/models.MapSummaryResponse" |
| 451 | { | ||
| 452 | "$ref": "#/definitions/models.Map" | ||
| 453 | }, | ||
| 454 | { | ||
| 455 | "type": "object", | ||
| 456 | "properties": { | ||
| 457 | "data": { | ||
| 458 | "$ref": "#/definitions/models.MapSummary" | ||
| 459 | } | ||
| 460 | } | ||
| 461 | } | ||
| 462 | ] | ||
| 463 | } | 451 | } |
| 464 | } | 452 | } |
| 465 | } | 453 | } |
| @@ -560,19 +548,7 @@ const docTemplate = `{ | |||
| 560 | "200": { | 548 | "200": { |
| 561 | "description": "OK", | 549 | "description": "OK", |
| 562 | "schema": { | 550 | "schema": { |
| 563 | "allOf": [ | 551 | "$ref": "#/definitions/models.Response" |
| 564 | { | ||
| 565 | "$ref": "#/definitions/models.Response" | ||
| 566 | }, | ||
| 567 | { | ||
| 568 | "type": "object", | ||
| 569 | "properties": { | ||
| 570 | "data": { | ||
| 571 | "$ref": "#/definitions/models.ProfileResponse" | ||
| 572 | } | ||
| 573 | } | ||
| 574 | } | ||
| 575 | ] | ||
| 576 | } | 552 | } |
| 577 | }, | 553 | }, |
| 578 | "400": { | 554 | "400": { |
| @@ -817,6 +793,17 @@ const docTemplate = `{ | |||
| 817 | } | 793 | } |
| 818 | }, | 794 | }, |
| 819 | "definitions": { | 795 | "definitions": { |
| 796 | "models.Category": { | ||
| 797 | "type": "object", | ||
| 798 | "properties": { | ||
| 799 | "id": { | ||
| 800 | "type": "integer" | ||
| 801 | }, | ||
| 802 | "name": { | ||
| 803 | "type": "string" | ||
| 804 | } | ||
| 805 | } | ||
| 806 | }, | ||
| 820 | "models.Chapter": { | 807 | "models.Chapter": { |
| 821 | "type": "object", | 808 | "type": "object", |
| 822 | "properties": { | 809 | "properties": { |
| @@ -881,7 +868,6 @@ const docTemplate = `{ | |||
| 881 | "chapter_name": { | 868 | "chapter_name": { |
| 882 | "type": "string" | 869 | "type": "string" |
| 883 | }, | 870 | }, |
| 884 | "data": {}, | ||
| 885 | "game_name": { | 871 | "game_name": { |
| 886 | "type": "string" | 872 | "type": "string" |
| 887 | }, | 873 | }, |
| @@ -893,23 +879,6 @@ const docTemplate = `{ | |||
| 893 | } | 879 | } |
| 894 | } | 880 | } |
| 895 | }, | 881 | }, |
| 896 | "models.MapCategoryScores": { | ||
| 897 | "type": "object", | ||
| 898 | "properties": { | ||
| 899 | "any": { | ||
| 900 | "type": "integer" | ||
| 901 | }, | ||
| 902 | "cm": { | ||
| 903 | "type": "integer" | ||
| 904 | }, | ||
| 905 | "inbounds_sla": { | ||
| 906 | "type": "integer" | ||
| 907 | }, | ||
| 908 | "no_sla": { | ||
| 909 | "type": "integer" | ||
| 910 | } | ||
| 911 | } | ||
| 912 | }, | ||
| 913 | "models.MapHistory": { | 882 | "models.MapHistory": { |
| 914 | "type": "object", | 883 | "type": "object", |
| 915 | "properties": { | 884 | "properties": { |
| @@ -930,6 +899,23 @@ const docTemplate = `{ | |||
| 930 | "records": {} | 899 | "records": {} |
| 931 | } | 900 | } |
| 932 | }, | 901 | }, |
| 902 | "models.MapRoute": { | ||
| 903 | "type": "object", | ||
| 904 | "properties": { | ||
| 905 | "category": { | ||
| 906 | "$ref": "#/definitions/models.Category" | ||
| 907 | }, | ||
| 908 | "description": { | ||
| 909 | "type": "string" | ||
| 910 | }, | ||
| 911 | "score_count": { | ||
| 912 | "type": "integer" | ||
| 913 | }, | ||
| 914 | "showcase": { | ||
| 915 | "type": "string" | ||
| 916 | } | ||
| 917 | } | ||
| 918 | }, | ||
| 933 | "models.MapShort": { | 919 | "models.MapShort": { |
| 934 | "type": "object", | 920 | "type": "object", |
| 935 | "properties": { | 921 | "properties": { |
| @@ -944,12 +930,6 @@ const docTemplate = `{ | |||
| 944 | "models.MapSummary": { | 930 | "models.MapSummary": { |
| 945 | "type": "object", | 931 | "type": "object", |
| 946 | "properties": { | 932 | "properties": { |
| 947 | "category_scores": { | ||
| 948 | "$ref": "#/definitions/models.MapCategoryScores" | ||
| 949 | }, | ||
| 950 | "description": { | ||
| 951 | "type": "string" | ||
| 952 | }, | ||
| 953 | "history": { | 933 | "history": { |
| 954 | "type": "array", | 934 | "type": "array", |
| 955 | "items": { | 935 | "items": { |
| @@ -959,14 +939,22 @@ const docTemplate = `{ | |||
| 959 | "rating": { | 939 | "rating": { |
| 960 | "type": "number" | 940 | "type": "number" |
| 961 | }, | 941 | }, |
| 962 | "routers": { | 942 | "routes": { |
| 963 | "type": "array", | 943 | "type": "array", |
| 964 | "items": { | 944 | "items": { |
| 965 | "type": "string" | 945 | "$ref": "#/definitions/models.MapRoute" |
| 966 | } | 946 | } |
| 947 | } | ||
| 948 | } | ||
| 949 | }, | ||
| 950 | "models.MapSummaryResponse": { | ||
| 951 | "type": "object", | ||
| 952 | "properties": { | ||
| 953 | "map": { | ||
| 954 | "$ref": "#/definitions/models.Map" | ||
| 967 | }, | 955 | }, |
| 968 | "showcase": { | 956 | "summary": { |
| 969 | "type": "string" | 957 | "$ref": "#/definitions/models.MapSummary" |
| 970 | } | 958 | } |
| 971 | } | 959 | } |
| 972 | }, | 960 | }, |
| @@ -1069,29 +1057,13 @@ const docTemplate = `{ | |||
| 1069 | "maps": { | 1057 | "maps": { |
| 1070 | "type": "array", | 1058 | "type": "array", |
| 1071 | "items": { | 1059 | "items": { |
| 1072 | "type": "object", | 1060 | "$ref": "#/definitions/models.MapShort" |
| 1073 | "properties": { | ||
| 1074 | "id": { | ||
| 1075 | "type": "integer" | ||
| 1076 | }, | ||
| 1077 | "name": { | ||
| 1078 | "type": "string" | ||
| 1079 | } | ||
| 1080 | } | ||
| 1081 | } | 1061 | } |
| 1082 | }, | 1062 | }, |
| 1083 | "players": { | 1063 | "players": { |
| 1084 | "type": "array", | 1064 | "type": "array", |
| 1085 | "items": { | 1065 | "items": { |
| 1086 | "type": "object", | 1066 | "$ref": "#/definitions/models.UserShort" |
| 1087 | "properties": { | ||
| 1088 | "steam_id": { | ||
| 1089 | "type": "string" | ||
| 1090 | }, | ||
| 1091 | "user_name": { | ||
| 1092 | "type": "string" | ||
| 1093 | } | ||
| 1094 | } | ||
| 1095 | } | 1067 | } |
| 1096 | } | 1068 | } |
| 1097 | } | 1069 | } |
| @@ -1109,6 +1081,17 @@ const docTemplate = `{ | |||
| 1109 | "type": "string" | 1081 | "type": "string" |
| 1110 | } | 1082 | } |
| 1111 | } | 1083 | } |
| 1084 | }, | ||
| 1085 | "models.UserShort": { | ||
| 1086 | "type": "object", | ||
| 1087 | "properties": { | ||
| 1088 | "steam_id": { | ||
| 1089 | "type": "string" | ||
| 1090 | }, | ||
| 1091 | "user_name": { | ||
| 1092 | "type": "string" | ||
| 1093 | } | ||
| 1094 | } | ||
| 1112 | } | 1095 | } |
| 1113 | } | 1096 | } |
| 1114 | }` | 1097 | }` |
diff --git a/docs/swagger.json b/docs/swagger.json index 8491d2e..f2ed3f0 100644 --- a/docs/swagger.json +++ b/docs/swagger.json | |||
| @@ -440,19 +440,7 @@ | |||
| 440 | "type": "object", | 440 | "type": "object", |
| 441 | "properties": { | 441 | "properties": { |
| 442 | "data": { | 442 | "data": { |
| 443 | "allOf": [ | 443 | "$ref": "#/definitions/models.MapSummaryResponse" |
| 444 | { | ||
| 445 | "$ref": "#/definitions/models.Map" | ||
| 446 | }, | ||
| 447 | { | ||
| 448 | "type": "object", | ||
| 449 | "properties": { | ||
| 450 | "data": { | ||
| 451 | "$ref": "#/definitions/models.MapSummary" | ||
| 452 | } | ||
| 453 | } | ||
| 454 | } | ||
| 455 | ] | ||
| 456 | } | 444 | } |
| 457 | } | 445 | } |
| 458 | } | 446 | } |
| @@ -553,19 +541,7 @@ | |||
| 553 | "200": { | 541 | "200": { |
| 554 | "description": "OK", | 542 | "description": "OK", |
| 555 | "schema": { | 543 | "schema": { |
| 556 | "allOf": [ | 544 | "$ref": "#/definitions/models.Response" |
| 557 | { | ||
| 558 | "$ref": "#/definitions/models.Response" | ||
| 559 | }, | ||
| 560 | { | ||
| 561 | "type": "object", | ||
| 562 | "properties": { | ||
| 563 | "data": { | ||
| 564 | "$ref": "#/definitions/models.ProfileResponse" | ||
| 565 | } | ||
| 566 | } | ||
| 567 | } | ||
| 568 | ] | ||
| 569 | } | 545 | } |
| 570 | }, | 546 | }, |
| 571 | "400": { | 547 | "400": { |
| @@ -810,6 +786,17 @@ | |||
| 810 | } | 786 | } |
| 811 | }, | 787 | }, |
| 812 | "definitions": { | 788 | "definitions": { |
| 789 | "models.Category": { | ||
| 790 | "type": "object", | ||
| 791 | "properties": { | ||
| 792 | "id": { | ||
| 793 | "type": "integer" | ||
| 794 | }, | ||
| 795 | "name": { | ||
| 796 | "type": "string" | ||
| 797 | } | ||
| 798 | } | ||
| 799 | }, | ||
| 813 | "models.Chapter": { | 800 | "models.Chapter": { |
| 814 | "type": "object", | 801 | "type": "object", |
| 815 | "properties": { | 802 | "properties": { |
| @@ -874,7 +861,6 @@ | |||
| 874 | "chapter_name": { | 861 | "chapter_name": { |
| 875 | "type": "string" | 862 | "type": "string" |
| 876 | }, | 863 | }, |
| 877 | "data": {}, | ||
| 878 | "game_name": { | 864 | "game_name": { |
| 879 | "type": "string" | 865 | "type": "string" |
| 880 | }, | 866 | }, |
| @@ -886,23 +872,6 @@ | |||
| 886 | } | 872 | } |
| 887 | } | 873 | } |
| 888 | }, | 874 | }, |
| 889 | "models.MapCategoryScores": { | ||
| 890 | "type": "object", | ||
| 891 | "properties": { | ||
| 892 | "any": { | ||
| 893 | "type": "integer" | ||
| 894 | }, | ||
| 895 | "cm": { | ||
| 896 | "type": "integer" | ||
| 897 | }, | ||
| 898 | "inbounds_sla": { | ||
| 899 | "type": "integer" | ||
| 900 | }, | ||
| 901 | "no_sla": { | ||
| 902 | "type": "integer" | ||
| 903 | } | ||
| 904 | } | ||
| 905 | }, | ||
| 906 | "models.MapHistory": { | 875 | "models.MapHistory": { |
| 907 | "type": "object", | 876 | "type": "object", |
| 908 | "properties": { | 877 | "properties": { |
| @@ -923,6 +892,23 @@ | |||
| 923 | "records": {} | 892 | "records": {} |
| 924 | } | 893 | } |
| 925 | }, | 894 | }, |
| 895 | "models.MapRoute": { | ||
| 896 | "type": "object", | ||
| 897 | "properties": { | ||
| 898 | "category": { | ||
| 899 | "$ref": "#/definitions/models.Category" | ||
| 900 | }, | ||
| 901 | "description": { | ||
| 902 | "type": "string" | ||
| 903 | }, | ||
| 904 | "score_count": { | ||
| 905 | "type": "integer" | ||
| 906 | }, | ||
| 907 | "showcase": { | ||
| 908 | "type": "string" | ||
| 909 | } | ||
| 910 | } | ||
| 911 | }, | ||
| 926 | "models.MapShort": { | 912 | "models.MapShort": { |
| 927 | "type": "object", | 913 | "type": "object", |
| 928 | "properties": { | 914 | "properties": { |
| @@ -937,12 +923,6 @@ | |||
| 937 | "models.MapSummary": { | 923 | "models.MapSummary": { |
| 938 | "type": "object", | 924 | "type": "object", |
| 939 | "properties": { | 925 | "properties": { |
| 940 | "category_scores": { | ||
| 941 | "$ref": "#/definitions/models.MapCategoryScores" | ||
| 942 | }, | ||
| 943 | "description": { | ||
| 944 | "type": "string" | ||
| 945 | }, | ||
| 946 | "history": { | 926 | "history": { |
| 947 | "type": "array", | 927 | "type": "array", |
| 948 | "items": { | 928 | "items": { |
| @@ -952,14 +932,22 @@ | |||
| 952 | "rating": { | 932 | "rating": { |
| 953 | "type": "number" | 933 | "type": "number" |
| 954 | }, | 934 | }, |
| 955 | "routers": { | 935 | "routes": { |
| 956 | "type": "array", | 936 | "type": "array", |
| 957 | "items": { | 937 | "items": { |
| 958 | "type": "string" | 938 | "$ref": "#/definitions/models.MapRoute" |
| 959 | } | 939 | } |
| 940 | } | ||
| 941 | } | ||
| 942 | }, | ||
| 943 | "models.MapSummaryResponse": { | ||
| 944 | "type": "object", | ||
| 945 | "properties": { | ||
| 946 | "map": { | ||
| 947 | "$ref": "#/definitions/models.Map" | ||
| 960 | }, | 948 | }, |
| 961 | "showcase": { | 949 | "summary": { |
| 962 | "type": "string" | 950 | "$ref": "#/definitions/models.MapSummary" |
| 963 | } | 951 | } |
| 964 | } | 952 | } |
| 965 | }, | 953 | }, |
| @@ -1062,29 +1050,13 @@ | |||
| 1062 | "maps": { | 1050 | "maps": { |
| 1063 | "type": "array", | 1051 | "type": "array", |
| 1064 | "items": { | 1052 | "items": { |
| 1065 | "type": "object", | 1053 | "$ref": "#/definitions/models.MapShort" |
| 1066 | "properties": { | ||
| 1067 | "id": { | ||
| 1068 | "type": "integer" | ||
| 1069 | }, | ||
| 1070 | "name": { | ||
| 1071 | "type": "string" | ||
| 1072 | } | ||
| 1073 | } | ||
| 1074 | } | 1054 | } |
| 1075 | }, | 1055 | }, |
| 1076 | "players": { | 1056 | "players": { |
| 1077 | "type": "array", | 1057 | "type": "array", |
| 1078 | "items": { | 1058 | "items": { |
| 1079 | "type": "object", | 1059 | "$ref": "#/definitions/models.UserShort" |
| 1080 | "properties": { | ||
| 1081 | "steam_id": { | ||
| 1082 | "type": "string" | ||
| 1083 | }, | ||
| 1084 | "user_name": { | ||
| 1085 | "type": "string" | ||
| 1086 | } | ||
| 1087 | } | ||
| 1088 | } | 1060 | } |
| 1089 | } | 1061 | } |
| 1090 | } | 1062 | } |
| @@ -1102,6 +1074,17 @@ | |||
| 1102 | "type": "string" | 1074 | "type": "string" |
| 1103 | } | 1075 | } |
| 1104 | } | 1076 | } |
| 1077 | }, | ||
| 1078 | "models.UserShort": { | ||
| 1079 | "type": "object", | ||
| 1080 | "properties": { | ||
| 1081 | "steam_id": { | ||
| 1082 | "type": "string" | ||
| 1083 | }, | ||
| 1084 | "user_name": { | ||
| 1085 | "type": "string" | ||
| 1086 | } | ||
| 1087 | } | ||
| 1105 | } | 1088 | } |
| 1106 | } | 1089 | } |
| 1107 | } \ No newline at end of file | 1090 | } \ No newline at end of file |
diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 597df9f..61f2ad7 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml | |||
| @@ -1,5 +1,12 @@ | |||
| 1 | basePath: /v1 | 1 | basePath: /v1 |
| 2 | definitions: | 2 | definitions: |
| 3 | models.Category: | ||
| 4 | properties: | ||
| 5 | id: | ||
| 6 | type: integer | ||
| 7 | name: | ||
| 8 | type: string | ||
| 9 | type: object | ||
| 3 | models.Chapter: | 10 | models.Chapter: |
| 4 | properties: | 11 | properties: |
| 5 | id: | 12 | id: |
| @@ -41,7 +48,6 @@ definitions: | |||
| 41 | properties: | 48 | properties: |
| 42 | chapter_name: | 49 | chapter_name: |
| 43 | type: string | 50 | type: string |
| 44 | data: {} | ||
| 45 | game_name: | 51 | game_name: |
| 46 | type: string | 52 | type: string |
| 47 | id: | 53 | id: |
| @@ -49,17 +55,6 @@ definitions: | |||
| 49 | map_name: | 55 | map_name: |
| 50 | type: string | 56 | type: string |
| 51 | type: object | 57 | type: object |
| 52 | models.MapCategoryScores: | ||
| 53 | properties: | ||
| 54 | any: | ||
| 55 | type: integer | ||
| 56 | cm: | ||
| 57 | type: integer | ||
| 58 | inbounds_sla: | ||
| 59 | type: integer | ||
| 60 | no_sla: | ||
| 61 | type: integer | ||
| 62 | type: object | ||
| 63 | models.MapHistory: | 58 | models.MapHistory: |
| 64 | properties: | 59 | properties: |
| 65 | date: | 60 | date: |
| @@ -73,6 +68,17 @@ definitions: | |||
| 73 | properties: | 68 | properties: |
| 74 | records: {} | 69 | records: {} |
| 75 | type: object | 70 | type: object |
| 71 | models.MapRoute: | ||
| 72 | properties: | ||
| 73 | category: | ||
| 74 | $ref: '#/definitions/models.Category' | ||
| 75 | description: | ||
| 76 | type: string | ||
| 77 | score_count: | ||
| 78 | type: integer | ||
| 79 | showcase: | ||
| 80 | type: string | ||
| 81 | type: object | ||
| 76 | models.MapShort: | 82 | models.MapShort: |
| 77 | properties: | 83 | properties: |
| 78 | id: | 84 | id: |
| @@ -82,22 +88,23 @@ definitions: | |||
| 82 | type: object | 88 | type: object |
| 83 | models.MapSummary: | 89 | models.MapSummary: |
| 84 | properties: | 90 | properties: |
| 85 | category_scores: | ||
| 86 | $ref: '#/definitions/models.MapCategoryScores' | ||
| 87 | description: | ||
| 88 | type: string | ||
| 89 | history: | 91 | history: |
| 90 | items: | 92 | items: |
| 91 | $ref: '#/definitions/models.MapHistory' | 93 | $ref: '#/definitions/models.MapHistory' |
| 92 | type: array | 94 | type: array |
| 93 | rating: | 95 | rating: |
| 94 | type: number | 96 | type: number |
| 95 | routers: | 97 | routes: |
| 96 | items: | 98 | items: |
| 97 | type: string | 99 | $ref: '#/definitions/models.MapRoute' |
| 98 | type: array | 100 | type: array |
| 99 | showcase: | 101 | type: object |
| 100 | type: string | 102 | models.MapSummaryResponse: |
| 103 | properties: | ||
| 104 | map: | ||
| 105 | $ref: '#/definitions/models.Map' | ||
| 106 | summary: | ||
| 107 | $ref: '#/definitions/models.MapSummary' | ||
| 101 | type: object | 108 | type: object |
| 102 | models.ProfileResponse: | 109 | models.ProfileResponse: |
| 103 | properties: | 110 | properties: |
| @@ -165,21 +172,11 @@ definitions: | |||
| 165 | properties: | 172 | properties: |
| 166 | maps: | 173 | maps: |
| 167 | items: | 174 | items: |
| 168 | properties: | 175 | $ref: '#/definitions/models.MapShort' |
| 169 | id: | ||
| 170 | type: integer | ||
| 171 | name: | ||
| 172 | type: string | ||
| 173 | type: object | ||
| 174 | type: array | 176 | type: array |
| 175 | players: | 177 | players: |
| 176 | items: | 178 | items: |
| 177 | properties: | 179 | $ref: '#/definitions/models.UserShort' |
| 178 | steam_id: | ||
| 179 | type: string | ||
| 180 | user_name: | ||
| 181 | type: string | ||
| 182 | type: object | ||
| 183 | type: array | 180 | type: array |
| 184 | type: object | 181 | type: object |
| 185 | models.UserRanking: | 182 | models.UserRanking: |
| @@ -191,6 +188,13 @@ definitions: | |||
| 191 | user_name: | 188 | user_name: |
| 192 | type: string | 189 | type: string |
| 193 | type: object | 190 | type: object |
| 191 | models.UserShort: | ||
| 192 | properties: | ||
| 193 | steam_id: | ||
| 194 | type: string | ||
| 195 | user_name: | ||
| 196 | type: string | ||
| 197 | type: object | ||
| 194 | host: lp.ardapektezol.com/api | 198 | host: lp.ardapektezol.com/api |
| 195 | info: | 199 | info: |
| 196 | contact: {} | 200 | contact: {} |
| @@ -456,12 +460,7 @@ paths: | |||
| 456 | - $ref: '#/definitions/models.Response' | 460 | - $ref: '#/definitions/models.Response' |
| 457 | - properties: | 461 | - properties: |
| 458 | data: | 462 | data: |
| 459 | allOf: | 463 | $ref: '#/definitions/models.MapSummaryResponse' |
| 460 | - $ref: '#/definitions/models.Map' | ||
| 461 | - properties: | ||
| 462 | data: | ||
| 463 | $ref: '#/definitions/models.MapSummary' | ||
| 464 | type: object | ||
| 465 | type: object | 464 | type: object |
| 466 | "400": | 465 | "400": |
| 467 | description: Bad Request | 466 | description: Bad Request |
| @@ -555,12 +554,7 @@ paths: | |||
| 555 | "200": | 554 | "200": |
| 556 | description: OK | 555 | description: OK |
| 557 | schema: | 556 | schema: |
| 558 | allOf: | 557 | $ref: '#/definitions/models.Response' |
| 559 | - $ref: '#/definitions/models.Response' | ||
| 560 | - properties: | ||
| 561 | data: | ||
| 562 | $ref: '#/definitions/models.ProfileResponse' | ||
| 563 | type: object | ||
| 564 | "400": | 558 | "400": |
| 565 | description: Bad Request | 559 | description: Bad Request |
| 566 | schema: | 560 | schema: |