From b70d5df5c2c5973085f349bdb13dee3552d152f5 Mon Sep 17 00:00:00 2001 From: ABDUL SATTAR MAPARA <32198670+abdulsmapara@users.noreply.github.com> Date: Mon, 9 Mar 2020 19:43:02 +0530 Subject: [PATCH] Added documentation to a few methods of sql store 'SqlTeamStore' (#14016) * Added documentation to a few methods of sql store 'SqlTeamStore' * Update store/sqlstore/team_store.go Co-Authored-By: Bot from GolangCI <42910462+golangcibot@users.noreply.github.com> * Update store/sqlstore/team_store.go Co-Authored-By: Bot from GolangCI <42910462+golangcibot@users.noreply.github.com> * Added documentation to a few methods of sql store 'SqlTeamStore' * Corrected documentation for Save method * Updated store/sqlstore/team_store.go Co-Authored-By: Justine Geffen Co-authored-by: Bot from GolangCI <42910462+golangcibot@users.noreply.github.com> Co-authored-by: Justine Geffen --- store/sqlstore/team_store.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/store/sqlstore/team_store.go b/store/sqlstore/team_store.go index cf5555e963..9adc9917f4 100644 --- a/store/sqlstore/team_store.go +++ b/store/sqlstore/team_store.go @@ -188,6 +188,8 @@ func (s SqlTeamStore) createIndexesIfNotExists() { s.CreateIndexIfNotExists("idx_teammembers_delete_at", "TeamMembers", "DeleteAt") } +// Save adds the team to the database if a team with the same name does not already +// exist in the database. It returns the team added if the operation is successful. func (s SqlTeamStore) Save(team *model.Team) (*model.Team, *model.AppError) { if len(team.Id) > 0 { return nil, model.NewAppError("SqlTeamStore.Save", @@ -209,6 +211,9 @@ func (s SqlTeamStore) Save(team *model.Team) (*model.Team, *model.AppError) { return team, nil } +// Update updates the details of the team passed as the parameter using the team Id +// if the team exists in the database. +// It returns the updated team if the operation is successful. func (s SqlTeamStore) Update(team *model.Team) (*model.Team, *model.AppError) { team.PreUpdate() @@ -528,6 +533,10 @@ func (s SqlTeamStore) getTeamMembersWithSchemeSelectQuery() sq.SelectBuilder { LeftJoin("Schemes TeamScheme ON Teams.SchemeId = TeamScheme.Id") } +// SaveMember adds a team member using the team Id of the member +// if the member does not already exist in the database and if the number +// of existing team members are less than the maximum allowed users per team. +// It returns the team member added if the operation is successful. func (s SqlTeamStore) SaveMember(member *model.TeamMember, maxUsersPerTeam int) (*model.TeamMember, *model.AppError) { defer s.InvalidateAllTeamIdsForUser(member.UserId) if err := member.IsValid(); err != nil { @@ -586,6 +595,8 @@ func (s SqlTeamStore) SaveMember(member *model.TeamMember, maxUsersPerTeam int) return retrievedMember.ToModel(), nil } +// UpdateMember updates the team member if the team member exists in the database. +// It returns the updated team member if the operation is successful. func (s SqlTeamStore) UpdateMember(member *model.TeamMember) (*model.TeamMember, *model.AppError) { member.PreUpdate()