Skip to content

Commit 4c1a70e

Browse files
authored
Merge pull request #49 from CodeChefVIT/revert-35-master
Revert "Get all female and fresher teams"
2 parents 58d9ea6 + 2f74973 commit 4c1a70e

File tree

7 files changed

+33
-148
lines changed

7 files changed

+33
-148
lines changed

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
version: '3'
22
services:
3-
43
api:
54
build: .
65
ports:
@@ -10,3 +9,4 @@ services:
109
env_file:
1110
- .env
1211
restart: on-failure
12+

go.mod

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,34 +20,28 @@ require (
2020
require (
2121
cloud.google.com/go/compute v1.23.3 // indirect
2222
cloud.google.com/go/compute/metadata v0.2.3 // indirect
23-
filippo.io/edwards25519 v1.1.0 // indirect
2423
github.com/cespare/xxhash/v2 v2.2.0 // indirect
2524
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
2625
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
2726
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
2827
github.com/go-playground/locales v0.14.1 // indirect
2928
github.com/go-playground/universal-translator v0.18.1 // indirect
30-
github.com/go-sql-driver/mysql v1.8.0 // indirect
3129
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
3230
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
3331
github.com/golang/protobuf v1.5.3 // indirect
3432
github.com/google/s2a-go v0.1.7 // indirect
3533
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
3634
github.com/googleapis/gax-go/v2 v2.12.0 // indirect
37-
github.com/grailbio-external/goose v4.0.1+incompatible // indirect
3835
github.com/jackc/pgpassfile v1.0.0 // indirect
3936
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
4037
github.com/jackc/puddle/v2 v2.2.1 // indirect
4138
github.com/labstack/gommon v0.4.2 // indirect
4239
github.com/leodido/go-urn v1.2.4 // indirect
43-
github.com/lib/pq v1.10.9 // indirect
4440
github.com/mattn/go-colorable v0.1.13 // indirect
4541
github.com/mattn/go-isatty v0.0.20 // indirect
46-
github.com/mattn/go-sqlite3 v1.14.22 // indirect
4742
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
4843
github.com/valyala/bytebufferpool v1.0.0 // indirect
4944
github.com/valyala/fasttemplate v1.2.2 // indirect
50-
github.com/ziutek/mymysql v1.5.4 // indirect
5145
go.opencensus.io v0.24.0 // indirect
5246
golang.org/x/net v0.20.0 // indirect
5347
golang.org/x/sync v0.5.0 // indirect

go.sum

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ cloud.google.com/go/compute v1.23.3 h1:6sVlXXBmbd7jNX0Ipq0trII3e4n1/MsADLK6a+aiV
33
cloud.google.com/go/compute v1.23.3/go.mod h1:VCgBUoMnIVIR0CscqQiPJLAG25E3ZRZMzcFZeQ+h8CI=
44
cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY=
55
cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA=
6-
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
7-
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
86
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
97
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
108
github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c=
@@ -35,8 +33,6 @@ github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJn
3533
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
3634
github.com/go-playground/validator/v10 v10.17.0 h1:SmVVlfAOtlZncTxRuinDPomC2DkXJ4E5T9gDA0AIH74=
3735
github.com/go-playground/validator/v10 v10.17.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
38-
github.com/go-sql-driver/mysql v1.8.0 h1:UtktXaU2Nb64z/pLiGIxY4431SJ4/dR5cjMmlVHgnT4=
39-
github.com/go-sql-driver/mysql v1.8.0/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg=
4036
github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY=
4137
github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
4238
github.com/golang-jwt/jwt/v5 v5.2.0 h1:d/ix8ftRUorsN+5eMIlF4T6J8CAt9rch3My2winC1Jw=
@@ -77,8 +73,6 @@ github.com/googleapis/enterprise-certificate-proxy v0.3.2 h1:Vie5ybvEvT75RniqhfF
7773
github.com/googleapis/enterprise-certificate-proxy v0.3.2/go.mod h1:VLSiSSBs/ksPL8kq3OBOQ6WRI2QnaFynd1DCjZ62+V0=
7874
github.com/googleapis/gax-go/v2 v2.12.0 h1:A+gCJKdRfqXkr+BIRGtZLibNXf0m1f9E4HG56etFpas=
7975
github.com/googleapis/gax-go/v2 v2.12.0/go.mod h1:y+aIqrI5eb1YGMVJfuV3185Ts/D7qKpsEkdD5+I6QGU=
80-
github.com/grailbio-external/goose v4.0.1+incompatible h1:jST4yUuBedXmgVCd6uLrIDzNurZKv2IkaZZRWnD4tuo=
81-
github.com/grailbio-external/goose v4.0.1+incompatible/go.mod h1:iT97/OP5V1NfG4dvLI1gtZeBrIxBClclzxBC1sUBWsc=
8276
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
8377
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
8478
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk=
@@ -95,15 +89,11 @@ github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0
9589
github.com/labstack/gommon v0.4.2/go.mod h1:QlUFxVM+SNXhDL/Z7YhocGIBYOiwB0mXm1+1bAPHPyU=
9690
github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q=
9791
github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4=
98-
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
99-
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
10092
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
10193
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
10294
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
10395
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
10496
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
105-
github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU=
106-
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
10797
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
10898
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
10999
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
@@ -125,8 +115,6 @@ github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6Kllzaw
125115
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
126116
github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo=
127117
github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
128-
github.com/ziutek/mymysql v1.5.4 h1:GB0qdRGsTwQSBVYuVShFBKaXSnSnYYC2d9knnE1LHFs=
129-
github.com/ziutek/mymysql v1.5.4/go.mod h1:LMSpPZ6DbqWFxNCHW77HeMg9I646SAhApZ/wKdgO/C0=
130118
go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0=
131119
go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo=
132120
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=

internal/controllers/admin_teams_controller.go

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func GetTeams(ctx echo.Context) error {
104104
return ctx.JSON(http.StatusAccepted, map[string]interface{}{
105105
"message": "Successfully fetched teams",
106106
"data": team,
107-
"status": "true",
107+
"status": "false",
108108
})
109109
}
110110

@@ -188,35 +188,3 @@ func GetTeamLeader(ctx echo.Context) error {
188188
})
189189

190190
}
191-
192-
func GetAllFresherTeams(ctx echo.Context) error {
193-
team, err := teamService.GetAllFresherTeam()
194-
if err != nil {
195-
return ctx.JSON(http.StatusBadRequest, map[string]string{
196-
"message": "Failed to fetch teams",
197-
"data": err.Error(),
198-
"status": "false",
199-
})
200-
}
201-
return ctx.JSON(http.StatusAccepted, map[string]interface{}{
202-
"message": "Successfully fetched teams",
203-
"data": team,
204-
"status": "true",
205-
})
206-
}
207-
208-
func GetAllFemaleTeams(ctx echo.Context) error {
209-
team, err := teamService.GetAllFemaleTeams()
210-
if err != nil {
211-
return ctx.JSON(http.StatusBadRequest, map[string]string{
212-
"message": "Failed to fetch teams",
213-
"data": err.Error(),
214-
"status": "false",
215-
})
216-
}
217-
return ctx.JSON(http.StatusAccepted, map[string]interface{}{
218-
"message": "Successfully fetched teams",
219-
"data": team,
220-
"status": "true",
221-
})
222-
}

internal/routes/admin_routes.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package routes
22

33
import (
44
"github.com/CodeChefVIT/devsoc-backend-24/internal/controllers"
5+
"github.com/CodeChefVIT/devsoc-backend-24/internal/middleware"
56
"github.com/labstack/echo/v4"
67
)
78

@@ -23,12 +24,9 @@ func AdminRoutes(incomingRoutes *echo.Echo) {
2324
admin.GET("/team/project/:id", controllers.GetProjectByTeamID)
2425
admin.GET("/team/leader/:id", controllers.GetTeamLeader)
2526
admin.GET("/team/idea/:id", controllers.GetIdeaByTeamID)
26-
admin.POST("/team/ban/:id", controllers.BanTeam)
27-
admin.POST("/team/unban/:id", controllers.UnbanTeam)
27+
admin.GET("/team/ban/:id", controllers.BanTeam)
28+
admin.GET("/team/unban/:id", controllers.UnbanTeam)
2829

2930
admin.GET("/projects/all", controllers.GetAllProject)
3031
admin.GET("/ideas/all", controllers.GetAllIdeas)
31-
32-
admin.GET("/team/freshers", controllers.GetAllFresherTeams)
33-
admin.GET("/team/females", controllers.GetAllFemaleTeams)
3432
}

internal/services/team/get_team.go

Lines changed: 28 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,15 @@ import (
1212

1313
func GetAllTeams() ([]models.GetTeam, error) {
1414
var teams []models.GetTeam
15-
teamMap := make(map[string]*models.GetTeam)
1615

17-
query := `SELECT teams.name, teams.code, teams.leader_id, teams.round,
18-
users.first_name, users.last_name, users.id, users.reg_no,
19-
ideas.title, ideas.description, ideas.track, ideas.github, ideas.figma, ideas.others,
20-
projects.name, projects.description, projects.github, projects.figma, projects.track, projects.others
21-
FROM teams
22-
INNER JOIN users ON users.team_id = teams.id
23-
LEFT JOIN projects ON teams.id = projects.teamid
24-
LEFT JOIN ideas ON teams.id = ideas.teamid`
16+
query := `SELECT teams.name,teams.code, teams.leader_id, teams.round ,
17+
users.first_name, users.last_name, users.id, users.reg_no,
18+
ideas.title, ideas.description, ideas.track, ideas.github, ideas.figma, ideas.others ,
19+
projects.name, projects.description, projects.github, projects.figma, projects.track, projects.others
20+
FROM teams
21+
INNER JOIN users ON users.team_id = teams.id
22+
LEFT JOIN projects ON teams.id = projects.teamid
23+
LEFT JOIN ideas ON teams.id = ideas.teamid`
2524

2625
rows, err := database.DB.Query(query)
2726
if err != nil {
@@ -36,7 +35,6 @@ func GetAllTeams() ([]models.GetTeam, error) {
3635

3736
for rows.Next() {
3837
var team models.GetTeam
39-
4038
values := make([]sql.NullString, len(columns))
4139
columnPointers := make([]interface{}, len(columns))
4240

@@ -47,30 +45,11 @@ func GetAllTeams() ([]models.GetTeam, error) {
4745
if err := rows.Scan(columnPointers...); err != nil {
4846
return teams, err
4947
}
50-
round, err := strconv.Atoi(values[3].String)
51-
if err != nil {
52-
return teams, err
53-
}
54-
teamCode := values[1].String
55-
if _, ok := teamMap[teamCode]; !ok {
56-
team = models.GetTeam{
57-
TeamName: values[0].String,
58-
TeamCode: teamCode,
59-
LeaderID: uuid.MustParse(values[2].String),
60-
Round: round,
61-
Ideas: models.Idea{},
62-
Project: models.Project{},
63-
Users: []models.GetUser{},
64-
}
65-
teamMap[teamCode] = &team
66-
}
6748

68-
user := models.GetUser{
69-
FullName: values[4].String + " " + values[5].String,
70-
RegNo: values[7].String,
71-
ID: uuid.MustParse(values[6].String),
72-
IsLeader: values[7].String == values[2].String,
73-
}
49+
team.TeamName = values[0].String
50+
team.TeamCode = values[1].String
51+
team.LeaderID = uuid.MustParse(values[2].String)
52+
team.Round, _ = strconv.Atoi(values[3].String)
7453

7554
if values[8].Valid {
7655
team.Ideas = models.Idea{
@@ -93,11 +72,23 @@ func GetAllTeams() ([]models.GetTeam, error) {
9372
Others: values[19].String,
9473
}
9574
}
96-
teamMap[teamCode].Users = append(teamMap[teamCode].Users, user)
97-
}
9875

99-
for _, team := range teamMap {
100-
teams = append(teams, *team)
76+
var isLeader bool
77+
if values[7].Valid {
78+
isLeader = values[7].String != ""
79+
} else {
80+
isLeader = false
81+
}
82+
83+
user := models.GetUser{
84+
FullName: values[4].String,
85+
RegNo: values[5].String,
86+
ID: uuid.MustParse(values[6].String),
87+
IsLeader: isLeader,
88+
}
89+
team.Users = append(team.Users, user)
90+
91+
teams = append(teams, team)
10192
}
10293

10394
return teams, nil
@@ -181,32 +172,3 @@ func FindTeamByCode(code string) (models.Team, error) {
181172

182173
return team, err
183174
}
184-
185-
func GetAllFresherTeam() ([]models.GetTeam, error) {
186-
var teamFresher []models.GetTeam
187-
teams, err := GetAllTeams()
188-
if err != nil {
189-
return teams, err
190-
}
191-
for _, team := range teams {
192-
if IsFresher(team) {
193-
teamFresher = append(teamFresher, team)
194-
}
195-
}
196-
return teamFresher, nil
197-
198-
}
199-
200-
func GetAllFemaleTeams() ([]models.GetTeam, error) {
201-
var teamFemale []models.GetTeam
202-
teams, err := GetAllTeams()
203-
if err != nil {
204-
return teams, err
205-
}
206-
for _, team := range teams {
207-
if IsFemale(team) {
208-
teamFemale = append(teamFemale, team)
209-
}
210-
}
211-
return teamFemale, nil
212-
}

internal/services/team/team_checks.go

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ import (
44
"github.com/google/uuid"
55

66
"github.com/CodeChefVIT/devsoc-backend-24/internal/database"
7-
"github.com/CodeChefVIT/devsoc-backend-24/internal/models"
8-
9-
services "github.com/CodeChefVIT/devsoc-backend-24/internal/services/user"
107
)
118

129
func CheckTeamCode(code string) bool {
@@ -41,25 +38,3 @@ func CheckUserInTeam(id uuid.UUID, teamid uuid.UUID) bool {
4138
}
4239
return true
4340
}
44-
45-
func IsFresher(team models.GetTeam) bool {
46-
for _, user := range team.Users {
47-
if user.RegNo[:2] != "23" {
48-
return false
49-
}
50-
}
51-
return true
52-
}
53-
54-
func IsFemale(team models.GetTeam) bool {
55-
for _, user := range team.Users {
56-
userData, err := services.FindUserByID(user.ID)
57-
if err != nil {
58-
return false
59-
}
60-
if userData.Gender != "Female" {
61-
return false
62-
}
63-
}
64-
return true
65-
}

0 commit comments

Comments
 (0)