diff options
| author | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2023-09-22 21:41:11 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-09-22 21:41:11 +0300 |
| commit | 30635edd4471b857feeda4545897f5372e584ad5 (patch) | |
| tree | c8093bc88795c4650c2741e9b6b37a8152e18135 /backend/handlers/home.go | |
| parent | feat: coop demos (#53) (diff) | |
| download | lphub-30635edd4471b857feeda4545897f5372e584ad5.tar.gz lphub-30635edd4471b857feeda4545897f5372e584ad5.tar.bz2 lphub-30635edd4471b857feeda4545897f5372e584ad5.zip | |
feat: improve map and user searches (#77)
Former-commit-id: 77019e11d0d0ee29061b603eaf6a79f42d68058f
Diffstat (limited to 'backend/handlers/home.go')
| -rw-r--r-- | backend/handlers/home.go | 247 |
1 files changed, 127 insertions, 120 deletions
diff --git a/backend/handlers/home.go b/backend/handlers/home.go index a2b7113..42e27be 100644 --- a/backend/handlers/home.go +++ b/backend/handlers/home.go | |||
| @@ -12,8 +12,8 @@ import ( | |||
| 12 | ) | 12 | ) |
| 13 | 13 | ||
| 14 | type SearchResponse struct { | 14 | type SearchResponse struct { |
| 15 | Players []models.UserShort `json:"players"` | 15 | Players []models.UserShortWithAvatar `json:"players"` |
| 16 | Maps []models.MapShort `json:"maps"` | 16 | Maps []MapShortWithGame `json:"maps"` |
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | type RankingsResponse struct { | 19 | type RankingsResponse struct { |
| @@ -22,6 +22,13 @@ type RankingsResponse struct { | |||
| 22 | Multiplayer []models.UserRanking `json:"rankings_multiplayer"` | 22 | Multiplayer []models.UserRanking `json:"rankings_multiplayer"` |
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | type MapShortWithGame struct { | ||
| 26 | ID int `json:"id"` | ||
| 27 | Game string `json:"game"` | ||
| 28 | Chapter string `json:"chapter"` | ||
| 29 | Map string `json:"map"` | ||
| 30 | } | ||
| 31 | |||
| 25 | // GET Rankings | 32 | // GET Rankings |
| 26 | // | 33 | // |
| 27 | // @Description Get rankings of every player. | 34 | // @Description Get rankings of every player. |
| @@ -143,143 +150,143 @@ func SearchWithQuery(c *gin.Context) { | |||
| 143 | log.Println(query) | 150 | log.Println(query) |
| 144 | var response SearchResponse | 151 | var response SearchResponse |
| 145 | // Cache all maps for faster response | 152 | // Cache all maps for faster response |
| 146 | var maps = []models.MapShort{ | 153 | var maps = []MapShortWithGame{ |
| 147 | {ID: 1, Name: "Container Ride"}, | 154 | {ID: 1, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 1 - The Courtesy Call", Map: "Container Ride"}, |
| 148 | {ID: 2, Name: "Portal Carousel"}, | 155 | {ID: 2, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 1 - The Courtesy Call", Map: "Portal Carousel"}, |
| 149 | {ID: 3, Name: "Portal Gun"}, | 156 | {ID: 3, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 1 - The Courtesy Call", Map: "Portal Gun"}, |
| 150 | {ID: 4, Name: "Smooth Jazz"}, | 157 | {ID: 4, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 1 - The Courtesy Call", Map: "Smooth Jazz"}, |
| 151 | {ID: 5, Name: "Cube Momentum"}, | 158 | {ID: 5, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 1 - The Courtesy Call", Map: "Cube Momentum"}, |
| 152 | {ID: 6, Name: "Future Starter"}, | 159 | {ID: 6, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 1 - The Courtesy Call", Map: "Future Starter"}, |
| 153 | {ID: 7, Name: "Secret Panel"}, | 160 | {ID: 7, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 1 - The Courtesy Call", Map: "Secret Panel"}, |
| 154 | {ID: 8, Name: "Wakeup"}, | 161 | {ID: 8, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 1 - The Courtesy Call", Map: "Wakeup"}, |
| 155 | {ID: 9, Name: "Incinerator"}, | 162 | {ID: 9, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 1 - The Courtesy Call", Map: "Incinerator"}, |
| 156 | {ID: 10, Name: "Laser Intro"}, | 163 | {ID: 10, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 2 - The Cold Boot", Map: "Laser Intro"}, |
| 157 | {ID: 11, Name: "Laser Stairs"}, | 164 | {ID: 11, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 2 - The Cold Boot", Map: "Laser Stairs"}, |
| 158 | {ID: 12, Name: "Dual Lasers"}, | 165 | {ID: 12, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 2 - The Cold Boot", Map: "Dual Lasers"}, |
| 159 | {ID: 13, Name: "Laser Over Goo"}, | 166 | {ID: 13, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 2 - The Cold Boot", Map: "Laser Over Goo"}, |
| 160 | {ID: 14, Name: "Catapult Intro"}, | 167 | {ID: 14, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 2 - The Cold Boot", Map: "Catapult Intro"}, |
| 161 | {ID: 15, Name: "Trust Fling"}, | 168 | {ID: 15, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 2 - The Cold Boot", Map: "Trust Fling"}, |
| 162 | {ID: 16, Name: "Pit Flings"}, | 169 | {ID: 16, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 2 - The Cold Boot", Map: "Pit Flings"}, |
| 163 | {ID: 17, Name: "Fizzler Intro"}, | 170 | {ID: 17, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 2 - The Cold Boot", Map: "Fizzler Intro"}, |
| 164 | {ID: 18, Name: "Ceiling Catapult"}, | 171 | {ID: 18, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 3 - The Return", Map: "Ceiling Catapult"}, |
| 165 | {ID: 19, Name: "Ricochet"}, | 172 | {ID: 19, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 3 - The Return", Map: "Ricochet"}, |
| 166 | {ID: 20, Name: "Bridge Intro"}, | 173 | {ID: 20, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 3 - The Return", Map: "Bridge Intro"}, |
| 167 | {ID: 21, Name: "Bridge The Gap"}, | 174 | {ID: 21, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 3 - The Return", Map: "Bridge The Gap"}, |
| 168 | {ID: 22, Name: "Turret Intro"}, | 175 | {ID: 22, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 3 - The Return", Map: "Turret Intro"}, |
| 169 | {ID: 23, Name: "Laser Relays"}, | 176 | {ID: 23, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 3 - The Return", Map: "Laser Relays"}, |
| 170 | {ID: 24, Name: "Turret Blocker"}, | 177 | {ID: 24, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 3 - The Return", Map: "Turret Blocker"}, |
| 171 | {ID: 25, Name: "Laser vs Turret"}, | 178 | {ID: 25, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 3 - The Return", Map: "Laser vs Turret"}, |
| 172 | {ID: 26, Name: "Pull The Rug"}, | 179 | {ID: 26, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 3 - The Return", Map: "Pull The Rug"}, |
| 173 | {ID: 27, Name: "Column Blocker"}, | 180 | {ID: 27, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 4 - The Surprise", Map: "Column Blocker"}, |
| 174 | {ID: 28, Name: "Laser Chaining"}, | 181 | {ID: 28, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 4 - The Surprise", Map: "Laser Chaining"}, |
| 175 | {ID: 29, Name: "Triple Laser"}, | 182 | {ID: 29, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 4 - The Surprise", Map: "Triple Laser"}, |
| 176 | {ID: 30, Name: "Jail Break"}, | 183 | {ID: 30, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 4 - The Surprise", Map: "Jail Break"}, |
| 177 | {ID: 31, Name: "Escape"}, | 184 | {ID: 31, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 4 - The Surprise", Map: "Escape"}, |
| 178 | {ID: 32, Name: "Turret Factory"}, | 185 | {ID: 32, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 5 - The Escape", Map: "Turret Factory"}, |
| 179 | {ID: 33, Name: "Turret Sabotage"}, | 186 | {ID: 33, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 5 - The Escape", Map: "Turret Sabotage"}, |
| 180 | {ID: 34, Name: "Neurotoxin Sabotage"}, | 187 | {ID: 34, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 5 - The Escape", Map: "Neurotoxin Sabotage"}, |
| 181 | {ID: 35, Name: "Core"}, | 188 | {ID: 35, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 5 - The Escape", Map: "Core"}, |
| 182 | {ID: 36, Name: "Underground"}, | 189 | {ID: 36, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 6 - The Fall", Map: "Underground"}, |
| 183 | {ID: 37, Name: "Cave Johnson"}, | 190 | {ID: 37, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 6 - The Fall", Map: "Cave Johnson"}, |
| 184 | {ID: 38, Name: "Repulsion Intro"}, | 191 | {ID: 38, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 6 - The Fall", Map: "Repulsion Intro"}, |
| 185 | {ID: 39, Name: "Bomb Flings"}, | 192 | {ID: 39, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 6 - The Fall", Map: "Bomb Flings"}, |
| 186 | {ID: 40, Name: "Crazy Box"}, | 193 | {ID: 40, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 6 - The Fall", Map: "Crazy Box"}, |
| 187 | {ID: 41, Name: "PotatOS"}, | 194 | {ID: 41, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 6 - The Fall", Map: "PotatOS"}, |
| 188 | {ID: 42, Name: "Propulsion Intro"}, | 195 | {ID: 42, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 7 - The Reunion", Map: "Propulsion Intro"}, |
| 189 | {ID: 43, Name: "Propulsion Flings"}, | 196 | {ID: 43, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 7 - The Reunion", Map: "Propulsion Flings"}, |
| 190 | {ID: 44, Name: "Conversion Intro"}, | 197 | {ID: 44, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 7 - The Reunion", Map: "Conversion Intro"}, |
| 191 | {ID: 45, Name: "Three Gels"}, | 198 | {ID: 45, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 7 - The Reunion", Map: "Three Gels"}, |
| 192 | {ID: 46, Name: "Test"}, | 199 | {ID: 46, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 8 - The Itch", Map: "Test"}, |
| 193 | {ID: 47, Name: "Funnel Intro"}, | 200 | {ID: 47, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 8 - The Itch", Map: "Funnel Intro"}, |
| 194 | {ID: 48, Name: "Ceiling Button"}, | 201 | {ID: 48, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 8 - The Itch", Map: "Ceiling Button"}, |
| 195 | {ID: 49, Name: "Wall Button"}, | 202 | {ID: 49, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 8 - The Itch", Map: "Wall Button"}, |
| 196 | {ID: 50, Name: "Polarity"}, | 203 | {ID: 50, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 8 - The Itch", Map: "Polarity"}, |
| 197 | {ID: 51, Name: "Funnel Catch"}, | 204 | {ID: 51, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 8 - The Itch", Map: "Funnel Catch"}, |
| 198 | {ID: 52, Name: "Stop The Box"}, | 205 | {ID: 52, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 8 - The Itch", Map: "Stop The Box"}, |
| 199 | {ID: 53, Name: "Laser Catapult"}, | 206 | {ID: 53, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 8 - The Itch", Map: "Laser Catapult"}, |
| 200 | {ID: 54, Name: "Laser Platform"}, | 207 | {ID: 54, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 8 - The Itch", Map: "Laser Platform"}, |
| 201 | {ID: 55, Name: "Propulsion Catch"}, | 208 | {ID: 55, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 8 - The Itch", Map: "Propulsion Catch"}, |
| 202 | {ID: 56, Name: "Repulsion Polarity"}, | 209 | {ID: 56, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 8 - The Itch", Map: "Repulsion Polarity"}, |
| 203 | {ID: 57, Name: "Finale 1"}, | 210 | {ID: 57, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 9 - The Part Where He Kills You", Map: "Finale 1"}, |
| 204 | {ID: 58, Name: "Finale 2"}, | 211 | {ID: 58, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 9 - The Part Where He Kills You", Map: "Finale 2"}, |
| 205 | {ID: 59, Name: "Finale 3"}, | 212 | {ID: 59, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 9 - The Part Where He Kills You", Map: "Finale 3"}, |
| 206 | {ID: 60, Name: "Finale 4"}, | 213 | {ID: 60, Game: "Portal 2 - Singleplayer", Chapter: "Chapter 9 - The Part Where He Kills You", Map: "Finale 4"}, |
| 207 | {ID: 61, Name: "Calibration"}, | 214 | {ID: 61, Game: "Portal 2 - Cooperative", Chapter: "Course 0 - Introduction", Map: "Calibration"}, |
| 208 | {ID: 62, Name: "Hub"}, | 215 | {ID: 62, Game: "Portal 2 - Cooperative", Chapter: "Course 0 - Introduction", Map: "Hub"}, |
| 209 | {ID: 63, Name: "Doors"}, | 216 | {ID: 63, Game: "Portal 2 - Cooperative", Chapter: "Course 1 - Team Building", Map: "Doors"}, |
| 210 | {ID: 64, Name: "Buttons"}, | 217 | {ID: 64, Game: "Portal 2 - Cooperative", Chapter: "Course 1 - Team Building", Map: "Buttons"}, |
| 211 | {ID: 65, Name: "Lasers"}, | 218 | {ID: 65, Game: "Portal 2 - Cooperative", Chapter: "Course 1 - Team Building", Map: "Lasers"}, |
| 212 | {ID: 66, Name: "Rat Maze"}, | 219 | {ID: 66, Game: "Portal 2 - Cooperative", Chapter: "Course 1 - Team Building", Map: "Rat Maze"}, |
| 213 | {ID: 67, Name: "Laser Crusher"}, | 220 | {ID: 67, Game: "Portal 2 - Cooperative", Chapter: "Course 1 - Team Building", Map: "Laser Crusher"}, |
| 214 | {ID: 68, Name: "Behind The Scenes"}, | 221 | {ID: 68, Game: "Portal 2 - Cooperative", Chapter: "Course 1 - Team Building", Map: "Behind The Scenes"}, |
| 215 | {ID: 69, Name: "Flings"}, | 222 | {ID: 69, Game: "Portal 2 - Cooperative", Chapter: "Course 2 - Mass And Velocity", Map: "Flings"}, |
| 216 | {ID: 70, Name: "Infinifling"}, | 223 | {ID: 70, Game: "Portal 2 - Cooperative", Chapter: "Course 2 - Mass And Velocity", Map: "Infinifling"}, |
| 217 | {ID: 71, Name: "Team Retrieval"}, | 224 | {ID: 71, Game: "Portal 2 - Cooperative", Chapter: "Course 2 - Mass And Velocity", Map: "Team Retrieval"}, |
| 218 | {ID: 72, Name: "Vertical Flings"}, | 225 | {ID: 72, Game: "Portal 2 - Cooperative", Chapter: "Course 2 - Mass And Velocity", Map: "Vertical Flings"}, |
| 219 | {ID: 73, Name: "Catapults"}, | 226 | {ID: 73, Game: "Portal 2 - Cooperative", Chapter: "Course 2 - Mass And Velocity", Map: "Catapults"}, |
| 220 | {ID: 74, Name: "Multifling"}, | 227 | {ID: 74, Game: "Portal 2 - Cooperative", Chapter: "Course 2 - Mass And Velocity", Map: "Multifling"}, |
| 221 | {ID: 75, Name: "Fling Crushers"}, | 228 | {ID: 75, Game: "Portal 2 - Cooperative", Chapter: "Course 2 - Mass And Velocity", Map: "Fling Crushers"}, |
| 222 | {ID: 76, Name: "Industrial Fan"}, | 229 | {ID: 76, Game: "Portal 2 - Cooperative", Chapter: "Course 2 - Mass And Velocity", Map: "Industrial Fan"}, |
| 223 | {ID: 77, Name: "Cooperative Bridges"}, | 230 | {ID: 77, Game: "Portal 2 - Cooperative", Chapter: "Course 3 - Hard-Light Surfaces", Map: "Cooperative Bridges"}, |
| 224 | {ID: 78, Name: "Bridge Swap"}, | 231 | {ID: 78, Game: "Portal 2 - Cooperative", Chapter: "Course 3 - Hard-Light Surfaces", Map: "Bridge Swap"}, |
| 225 | {ID: 79, Name: "Fling Block"}, | 232 | {ID: 79, Game: "Portal 2 - Cooperative", Chapter: "Course 3 - Hard-Light Surfaces", Map: "Fling Block"}, |
| 226 | {ID: 80, Name: "Catapult Block"}, | 233 | {ID: 80, Game: "Portal 2 - Cooperative", Chapter: "Course 3 - Hard-Light Surfaces", Map: "Catapult Block"}, |
| 227 | {ID: 81, Name: "Bridge Fling"}, | 234 | {ID: 81, Game: "Portal 2 - Cooperative", Chapter: "Course 3 - Hard-Light Surfaces", Map: "Bridge Fling"}, |
| 228 | {ID: 82, Name: "Turret Walls"}, | 235 | {ID: 82, Game: "Portal 2 - Cooperative", Chapter: "Course 3 - Hard-Light Surfaces", Map: "Turret Walls"}, |
| 229 | {ID: 83, Name: "Turret Assasin"}, | 236 | {ID: 83, Game: "Portal 2 - Cooperative", Chapter: "Course 3 - Hard-Light Surfaces", Map: "Turret Assasin"}, |
| 230 | {ID: 84, Name: "Bridge Testing"}, | 237 | {ID: 84, Game: "Portal 2 - Cooperative", Chapter: "Course 3 - Hard-Light Surfaces", Map: "Bridge Testing"}, |
| 231 | {ID: 85, Name: "Cooperative Funnels"}, | 238 | {ID: 85, Game: "Portal 2 - Cooperative", Chapter: "Course 4 - Excursion Funnels", Map: "Cooperative Funnels"}, |
| 232 | {ID: 86, Name: "Funnel Drill"}, | 239 | {ID: 86, Game: "Portal 2 - Cooperative", Chapter: "Course 4 - Excursion Funnels", Map: "Funnel Drill"}, |
| 233 | {ID: 87, Name: "Funnel Catch"}, | 240 | {ID: 87, Game: "Portal 2 - Cooperative", Chapter: "Course 4 - Excursion Funnels", Map: "Funnel Catch"}, |
| 234 | {ID: 88, Name: "Funnel Laser"}, | 241 | {ID: 88, Game: "Portal 2 - Cooperative", Chapter: "Course 4 - Excursion Funnels", Map: "Funnel Laser"}, |
| 235 | {ID: 89, Name: "Cooperative Polarity"}, | 242 | {ID: 89, Game: "Portal 2 - Cooperative", Chapter: "Course 4 - Excursion Funnels", Map: "Cooperative Polarity"}, |
| 236 | {ID: 90, Name: "Funnel Hop"}, | 243 | {ID: 90, Game: "Portal 2 - Cooperative", Chapter: "Course 4 - Excursion Funnels", Map: "Funnel Hop"}, |
| 237 | {ID: 91, Name: "Advanced Polarity"}, | 244 | {ID: 91, Game: "Portal 2 - Cooperative", Chapter: "Course 4 - Excursion Funnels", Map: "Advanced Polarity"}, |
| 238 | {ID: 92, Name: "Funnel Maze"}, | 245 | {ID: 92, Game: "Portal 2 - Cooperative", Chapter: "Course 4 - Excursion Funnels", Map: "Funnel Maze"}, |
| 239 | {ID: 93, Name: "Turret Warehouse"}, | 246 | {ID: 93, Game: "Portal 2 - Cooperative", Chapter: "Course 4 - Excursion Funnels", Map: "Turret Warehouse"}, |
| 240 | {ID: 94, Name: "Repulsion Jumps"}, | 247 | {ID: 94, Game: "Portal 2 - Cooperative", Chapter: "Course 5 - Mobility Gels", Map: "Repulsion Jumps"}, |
| 241 | {ID: 95, Name: "Double Bounce"}, | 248 | {ID: 95, Game: "Portal 2 - Cooperative", Chapter: "Course 5 - Mobility Gels", Map: "Double Bounce"}, |
| 242 | {ID: 96, Name: "Bridge Repulsion"}, | 249 | {ID: 96, Game: "Portal 2 - Cooperative", Chapter: "Course 5 - Mobility Gels", Map: "Bridge Repulsion"}, |
| 243 | {ID: 97, Name: "Wall Repulsion"}, | 250 | {ID: 97, Game: "Portal 2 - Cooperative", Chapter: "Course 5 - Mobility Gels", Map: "Wall Repulsion"}, |
| 244 | {ID: 98, Name: "Propulsion Crushers"}, | 251 | {ID: 98, Game: "Portal 2 - Cooperative", Chapter: "Course 5 - Mobility Gels", Map: "Propulsion Crushers"}, |
| 245 | {ID: 99, Name: "Turret Ninja"}, | 252 | {ID: 99, Game: "Portal 2 - Cooperative", Chapter: "Course 5 - Mobility Gels", Map: "Turret Ninja"}, |
| 246 | {ID: 100, Name: "Propulsion Retrieval"}, | 253 | {ID: 100, Game: "Portal 2 - Cooperative", Chapter: "Course 5 - Mobility Gels", Map: "Propulsion Retrieval"}, |
| 247 | {ID: 101, Name: "Vault Entrance"}, | 254 | {ID: 101, Game: "Portal 2 - Cooperative", Chapter: "Course 5 - Mobility Gels", Map: "Vault Entrance"}, |
| 248 | {ID: 102, Name: "Seperation"}, | 255 | {ID: 102, Game: "Portal 2 - Cooperative", Chapter: "Course 6 - Art Therapy", Map: "Seperation"}, |
| 249 | {ID: 103, Name: "Triple Axis"}, | 256 | {ID: 103, Game: "Portal 2 - Cooperative", Chapter: "Course 6 - Art Therapy", Map: "Triple Axis"}, |
| 250 | {ID: 104, Name: "Catapult Catch"}, | 257 | {ID: 104, Game: "Portal 2 - Cooperative", Chapter: "Course 6 - Art Therapy", Map: "Catapult Catch"}, |
| 251 | {ID: 105, Name: "Bridge Gels"}, | 258 | {ID: 105, Game: "Portal 2 - Cooperative", Chapter: "Course 6 - Art Therapy", Map: "Bridge Gels"}, |
| 252 | {ID: 106, Name: "Maintenance"}, | 259 | {ID: 106, Game: "Portal 2 - Cooperative", Chapter: "Course 6 - Art Therapy", Map: "Maintenance"}, |
| 253 | {ID: 107, Name: "Bridge Catch"}, | 260 | {ID: 107, Game: "Portal 2 - Cooperative", Chapter: "Course 6 - Art Therapy", Map: "Bridge Catch"}, |
| 254 | {ID: 108, Name: "Double Lift"}, | 261 | {ID: 108, Game: "Portal 2 - Cooperative", Chapter: "Course 6 - Art Therapy", Map: "Double Lift"}, |
| 255 | {ID: 109, Name: "Gel Maze"}, | 262 | {ID: 109, Game: "Portal 2 - Cooperative", Chapter: "Course 6 - Art Therapy", Map: "Gel Maze"}, |
| 256 | {ID: 110, Name: "Crazier Box"}, | 263 | {ID: 110, Game: "Portal 2 - Cooperative", Chapter: "Course 6 - Art Therapy", Map: "Crazier Box"}, |
| 257 | } | 264 | } |
| 258 | var filteredMaps []models.MapShort | 265 | var filteredMaps []MapShortWithGame |
| 259 | for _, m := range maps { | 266 | for _, m := range maps { |
| 260 | if strings.Contains(strings.ToLower(m.Name), strings.ToLower(query)) { | 267 | if strings.Contains(strings.ToLower(m.Map), strings.ToLower(query)) { |
| 261 | filteredMaps = append(filteredMaps, m) | 268 | filteredMaps = append(filteredMaps, m) |
| 262 | } | 269 | } |
| 263 | } | 270 | } |
| 264 | response.Maps = filteredMaps | 271 | response.Maps = filteredMaps |
| 265 | if len(response.Maps) == 0 { | 272 | if len(response.Maps) == 0 { |
| 266 | response.Maps = []models.MapShort{} | 273 | response.Maps = []MapShortWithGame{} |
| 267 | } | 274 | } |
| 268 | rows, err := database.DB.Query("SELECT steam_id, user_name FROM users WHERE lower(user_name) LIKE $1", "%"+query+"%") | 275 | rows, err := database.DB.Query("SELECT steam_id, user_name, avatar_link FROM users WHERE lower(user_name) LIKE $1", "%"+query+"%") |
| 269 | if err != nil { | 276 | if err != nil { |
| 270 | log.Fatal(err) | 277 | log.Fatal(err) |
| 271 | } | 278 | } |
| 272 | defer rows.Close() | 279 | defer rows.Close() |
| 273 | for rows.Next() { | 280 | for rows.Next() { |
| 274 | var user models.UserShort | 281 | var user models.UserShortWithAvatar |
| 275 | if err := rows.Scan(&user.SteamID, &user.UserName); err != nil { | 282 | if err := rows.Scan(&user.SteamID, &user.UserName, &user.AvatarLink); err != nil { |
| 276 | c.JSON(http.StatusOK, models.ErrorResponse(err.Error())) | 283 | c.JSON(http.StatusOK, models.ErrorResponse(err.Error())) |
| 277 | return | 284 | return |
| 278 | } | 285 | } |
| 279 | response.Players = append(response.Players, user) | 286 | response.Players = append(response.Players, user) |
| 280 | } | 287 | } |
| 281 | if len(response.Players) == 0 { | 288 | if len(response.Players) == 0 { |
| 282 | response.Players = []models.UserShort{} | 289 | response.Players = []models.UserShortWithAvatar{} |
| 283 | } | 290 | } |
| 284 | c.JSON(http.StatusOK, models.Response{ | 291 | c.JSON(http.StatusOK, models.Response{ |
| 285 | Success: true, | 292 | Success: true, |