Skip to content

[GUN-12] Create GET /teams/:teamname/members route#23

Open
laracarvalho wants to merge 11 commits into
developmentfrom
feature/get-team-members-route
Open

[GUN-12] Create GET /teams/:teamname/members route#23
laracarvalho wants to merge 11 commits into
developmentfrom
feature/get-team-members-route

Conversation

@laracarvalho

Copy link
Copy Markdown

Description:
This pull request aims to implement the route /teams/:teamname/members to return the list of Forjadev members from each team.

Issue: #12

Changes Made:

  • Created /teams/:teamname/members route at Gin router
  • Created handler ListTeamMembersHandler for /teams/:teamname/members route
  • Updated schemas for Members and Teams
  • Documented route with Swagger

@laracarvalho laracarvalho added the enhancement New feature or request label Aug 9, 2023
@laracarvalho laracarvalho self-assigned this Aug 9, 2023
@laracarvalho laracarvalho linked an issue Aug 9, 2023 that may be closed by this pull request
@MiguelMachado-dev
MiguelMachado-dev requested a review from a team August 9, 2023 23:36

@MiguelMachado-dev MiguelMachado-dev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks great, but, can we add a test to this route to make sure it returns everything perfect?

Comment thread handler/getTeamMembers.go
teamName := ctx.Param("teamname")

if teamName == "" {
sendError(ctx, 404, "Team name is required")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can use the http.StatusNotFound instead of the hardcoded http code for easy documentation and reading, what you think?

Comment thread handler/getTeamMembers.go
err := db.Joins("JOIN teams ON teams.team_id = member.team_id").Where("teams.name = ?", teamName).Find(&schemas.Member{})

if err != nil {
sendError(ctx, 404, "Team not found")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread schemas/team.go
}

type TeamNameRequest struct {
name string

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Attribute name should be in lowercase?

Comment thread handler/getTeamMembers.go
// @Produce json
// @Success 200 {object} ListTeamMembersResponse
// @Router /team/{teamname}/members [get]
func ListTeamMembersHandler(ctx *gin.Context) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The names ListTeam and getTeam, they have the same meaning, what do you think about choosing one to have a consistent nomenclature? Make sense?

Comment thread handler/getTeamMembers.go
Comment thread handler/handler.go

var db *gorm.DB

func InitiliazeHandler() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean Initialize?

Comment thread router/routes.go
// initializeRoutes sets up the routes for the application
func initializeRoutes(r *gin.Engine) {
// Initialize handler
handler.InitiliazeHandler()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here:
#23 (comment)

@rodrigofmeneses rodrigofmeneses left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work. Need just few improvements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create GET /teams/teamname/members route

5 participants