From 10ec7d977d270a535288311118d5020ac8a2babc Mon Sep 17 00:00:00 2001 From: viehlieb Date: Mon, 8 May 2023 16:04:49 +0200 Subject: [PATCH] refactor unused function GetTeamsByName --- pkg/models/error.go | 27 ++------------------------- pkg/models/teams.go | 18 ------------------ 2 files changed, 2 insertions(+), 43 deletions(-) diff --git a/pkg/models/error.go b/pkg/models/error.go index 7efaca871..5729c0902 100644 --- a/pkg/models/error.go +++ b/pkg/models/error.go @@ -1190,29 +1190,6 @@ func (err ErrTeamDoesNotHaveAccessToList) HTTPError() web.HTTPError { return web.HTTPError{HTTPCode: http.StatusForbidden, Code: ErrCodeTeamDoesNotHaveAccessToList, Message: "This team does not have access to the list."} } -// ErrTeamsDoNotExist represents an error where Teams searched via non-unique name do not exist. -type ErrTeamsDoNotExist struct { - Name string -} - -// IsErrTeamsDoNotExist checks if an error is ErrTeamsDoNotExist. -func IsErrTeamsDoNotExist(err error) bool { - _, ok := err.(ErrTeamsDoNotExist) - return ok -} - -func (err ErrTeamsDoNotExist) Error() string { - return fmt.Sprintf("No teams with that name exist [Team Name: %v]", err.Name) -} - -// ErrCodeTeamsDoesNotExist holds the unique world-error code of this error -const ErrCodeTeamsDoNotExist = 6008 - -// HTTPError holds the http error description -func (err ErrTeamsDoNotExist) HTTPError() web.HTTPError { - return web.HTTPError{HTTPCode: http.StatusNotFound, Code: ErrCodeTeamDoesNotExist, Message: "No teams with that name exist"} -} - // ErrOIDCTeamDoesNotExist represents an error where a team with specified name and specified oidcId property does not exist type ErrOIDCTeamDoesNotExist struct { OidcID string @@ -1231,7 +1208,7 @@ func (err ErrOIDCTeamDoesNotExist) Error() string { } // ErrCodeTeamDoesNotExist holds the unique world-error code of this error -const ErrCodeOIDCTeamDoesNotExist = 6009 +const ErrCodeOIDCTeamDoesNotExist = 6008 // HTTPError holds the http error description func (err ErrOIDCTeamDoesNotExist) HTTPError() web.HTTPError { @@ -1254,7 +1231,7 @@ func (err ErrOIDCTeamsDoNotExistForUser) Error() string { } // ErrCodeTeamDoesNotExist holds the unique world-error code of this error -const ErrCodeOIDCTeamsDoNotExistForUser = 6010 +const ErrCodeOIDCTeamsDoNotExistForUser = 6009 // HTTPError holds the http error description func (err ErrOIDCTeamsDoNotExistForUser) HTTPError() web.HTTPError { diff --git a/pkg/models/teams.go b/pkg/models/teams.go index c9b24acf4..355f79779 100644 --- a/pkg/models/teams.go +++ b/pkg/models/teams.go @@ -129,24 +129,6 @@ func GetTeamByID(s *xorm.Session, id int64) (team *Team, err error) { return } -// GetTeamByName gets teams by name -func GetTeamsByName(s *xorm.Session, name string) (teams []*Team, err error) { - if name == "" { - return teams, ErrTeamsDoNotExist{name} - } - - var ts []*Team - - err = s. - Where("name = ?", name). - Find(&ts) - if err != nil || len(ts) == 0 { - return ts, ErrTeamsDoNotExist{name} - } - teams = ts - return teams, err -} - // GetTeamByOidcIDAndName gets teams where oidc_id and name match parameters // For oidc team creation oidcID and Name need to be set func GetTeamByOidcIDAndName(s *xorm.Session, oidcID string, teamName string) (team Team, err error) {