refactor unused function GetTeamsByName

This commit is contained in:
viehlieb 2023-05-08 16:04:49 +02:00
parent 99ab09e705
commit c1826ff612
2 changed files with 2 additions and 43 deletions

View File

@ -1196,29 +1196,6 @@ func (err ErrOIDCTeamsDoNotExistForUser) HTTPError() web.HTTPError {
return web.HTTPError{HTTPCode: http.StatusNotFound, Code: ErrCodeTeamDoesNotExist, Message: "No Teams with property oidcId could be found for User."}
}
// 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
@ -1237,7 +1214,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 {
@ -1260,7 +1237,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 {

View File

@ -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) {