Skip to content

Commit 3f70b0f

Browse files
committed
added idea track filter
1 parent 0cc54b1 commit 3f70b0f

File tree

5 files changed

+148
-0
lines changed

5 files changed

+148
-0
lines changed

database/queries/teams.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ WHERE teams.name ILIKE '%' || $1 || '%'
1010
ORDER BY teams.id
1111
LIMIT $3;
1212

13+
-- name: GetTeamByTrack :many
14+
SELECT t.*, i.title, i.description, i.track
15+
FROM teams t
16+
LEFT JOIN ideas i ON i.team_id = t.id
17+
WHERE i.track = $1;
1318

1419
-- name: GetTeamById :one
1520
SELECT teams.id, teams.name, teams.round_qualified, teams.code,teams.is_banned,

docs/sample.yaml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2779,6 +2779,80 @@ paths:
27792779
type: string
27802780
example: unauthorized
27812781

2782+
/admin/teams/{track}:
2783+
get:
2784+
tags:
2785+
- Admin
2786+
summary: Get teams by track
2787+
description: Fetches teams associated with a specific track.
2788+
parameters:
2789+
- name: track
2790+
in: path
2791+
required: true
2792+
schema:
2793+
type: string
2794+
description: The track to filter teams by.
2795+
responses:
2796+
"200":
2797+
description: Successfully fetched teams
2798+
content:
2799+
application/json:
2800+
schema:
2801+
type: object
2802+
properties:
2803+
status:
2804+
type: string
2805+
example: success
2806+
message:
2807+
type: string
2808+
example: teams fetched successfully
2809+
data:
2810+
type: array
2811+
items:
2812+
type: object
2813+
properties:
2814+
id:
2815+
type: string
2816+
format: uuid
2817+
example: "550e8400-e29b-41d4-a716-446655440000"
2818+
title:
2819+
type: string
2820+
example: "Innovative AI Project"
2821+
description:
2822+
type: string
2823+
example: "A project focused on AI-driven solutions."
2824+
track:
2825+
type: string
2826+
example: "Artificial Intelligence"
2827+
name:
2828+
type: string
2829+
example: "Team Alpha"
2830+
number_of_people:
2831+
type: integer
2832+
example: 5
2833+
round_qualified:
2834+
type: integer
2835+
example: 1
2836+
code:
2837+
type: string
2838+
example: "TMAI1234"
2839+
is_banned:
2840+
type: boolean
2841+
example: false
2842+
"500":
2843+
description: Internal server error
2844+
content:
2845+
application/json:
2846+
schema:
2847+
type: object
2848+
properties:
2849+
status:
2850+
type: string
2851+
example: fail
2852+
message:
2853+
type: string
2854+
example: Internal server error
2855+
27822856
components:
27832857
schemas:
27842858
User:

pkg/controller/admin.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,25 @@ func GetTeamById(c echo.Context) error {
272272
})
273273
}
274274

275+
func GetTeamsByTrack(c echo.Context) error {
276+
ctx := c.Request().Context()
277+
track := c.Param("track")
278+
279+
teams, err := utils.Queries.GetTeamByTrack(ctx, track)
280+
if err != nil {
281+
return c.JSON(http.StatusInternalServerError, &models.Response{
282+
Status: "fail",
283+
Message: err.Error(),
284+
})
285+
}
286+
287+
return c.JSON(http.StatusOK, &models.Response{
288+
Status: "success",
289+
Message: "teams fetched successfully",
290+
Data: teams,
291+
})
292+
}
293+
275294
func GetTeamLeader(c echo.Context) error {
276295
teamIdParam := c.Param("id")
277296
teamId, err := uuid.Parse(teamIdParam)

pkg/db/teams.sql.go

Lines changed: 49 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/router/admin_routes.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ func AdminRoutes(incomingRoutes *echo.Group) {
2121
admin.GET("/teams/:id", controller.GetTeamById)
2222
admin.GET("/team/leader/:id", controller.GetTeamLeader)
2323
admin.POST("/createpanel", controller.CreatePanel)
24+
admin.GET("/teams/:track", controller.GetTeamsByTrack)
2425

2526
admin.GET("/members/:id", controller.GetAllTeamMembers)
2627
admin.POST("/ban/team", controller.BanTeam)

0 commit comments

Comments
 (0)