Skip to content

Commit fcd783c

Browse files
authored
Merge pull request #27 from RewanshChoudhary/master
Removed repeated team ban routes from admin
2 parents 72c5e68 + 55891d0 commit fcd783c

14 files changed

Lines changed: 838 additions & 9 deletions

File tree

.env.save

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

cmd/api/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func main() {
4242
"status": "devsoc-backend-26 running",
4343
})
4444
})
45-
45+
utils.InitValidator()
4646
e.Use(middlewares.RequestLogger)
4747
router.RegisterRoute(e)
4848

database/queries/teams.sql

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,12 @@ SET name = $1,
3333
is_banned = $4,
3434
total_score = $5
3535
WHERE id = $6;
36+
37+
38+
39+
-- name: GetTeamByTrack :many
40+
SELECT t.id, t.name, t.team_size, t.round_qualified, t.code, t.is_banned, i.title, i.description, i.track
41+
FROM teams t
42+
LEFT JOIN ideas i ON i.team_id = t.id
43+
WHERE i.track = $1;
44+

database/queries/users.sql

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,78 @@ SELECT id
3333
FROM users
3434
WHERE email = $1;
3535

36+
-- name: GetAllUsers :many
37+
SELECT
38+
u.id,
39+
u.team_id,
40+
u.name,
41+
u.email,
42+
u.phone_no,
43+
u.reg_no,
44+
u.gender,
45+
u.hostel_block,
46+
u.room_no,
47+
u.github_profile,
48+
u.role,
49+
u.is_leader,
50+
u.is_verified,
51+
u.is_banned,
52+
u.is_profile_complete,
53+
t.round_qualified
54+
FROM users u
55+
JOIN teams t
56+
ON t.id = u.team_id
57+
WHERE (
58+
$1 = ''
59+
OR u.name ILIKE '%' || $1 || '%'
60+
OR u.reg_no ILIKE '%' || $1 || '%'
61+
OR u.email ILIKE '%' || $1 || '%'
62+
)
63+
AND (
64+
$2::uuid IS NULL
65+
OR u.id > $2
66+
)
67+
AND (
68+
$4 = ''
69+
OR u.gender = $4
70+
)
71+
ORDER BY u.id
72+
LIMIT $3;
73+
74+
-- name: GetUsersByGender :many
75+
SELECT * FROM users WHERE gender = $1;
76+
77+
-- name: GetUsersByTeamId :many
78+
SELECT
79+
name,
80+
email,
81+
reg_no,
82+
phone_no,
83+
hostel_block
84+
FROM users
85+
WHERE team_id = $1::uuid;
86+
87+
-- name: GetUserByEmail :one
88+
SELECT * FROM users WHERE email = $1;
89+
3690
-- name: GetTeamIDByEmail :one
3791
SELECT team_id
3892
FROM users
3993
WHERE email = $1;
4094

95+
-- name: GetTeamLeaderByID :one
96+
SELECT *
97+
FROM users
98+
WHERE team_id = $1::uuid
99+
AND is_leader = true;
100+
101+
-- name: BanUser :exec
102+
UPDATE users
103+
SET is_banned = TRUE
104+
WHERE email = $1;
105+
106+
-- name: UnbanUser :exec
107+
UPDATE users
108+
SET is_banned = FALSE
109+
WHERE email = $1;
110+

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,4 @@ require (
4343
golang.org/x/sync v0.19.0 // indirect
4444
golang.org/x/sys v0.39.0 // indirect
4545
golang.org/x/text v0.32.0 // indirect
46-
golang.org/x/time v0.11.0 // indirect
4746
)

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,6 @@ golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk=
8989
golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
9090
golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU=
9191
golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY=
92-
golang.org/x/time v0.11.0 h1:/bpjEDfN9tkoN/ryeYHnv5hcMlc8ncjMcM4XBk5NWV0=
93-
golang.org/x/time v0.11.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg=
9492
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
9593
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
9694
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=

0 commit comments

Comments
 (0)