@@ -16,8 +16,6 @@ import (
16
16
user_model "code.gitea.io/gitea/models/user"
17
17
"code.gitea.io/gitea/modules/log"
18
18
"code.gitea.io/gitea/modules/util"
19
-
20
- "xorm.io/builder"
21
19
)
22
20
23
21
// ___________
@@ -96,59 +94,6 @@ func init() {
96
94
db .RegisterModel (new (TeamInvite ))
97
95
}
98
96
99
- // SearchTeamOptions holds the search options
100
- type SearchTeamOptions struct {
101
- db.ListOptions
102
- UserID int64
103
- Keyword string
104
- OrgID int64
105
- IncludeDesc bool
106
- }
107
-
108
- func (opts * SearchTeamOptions ) toCond () builder.Cond {
109
- cond := builder .NewCond ()
110
-
111
- if len (opts .Keyword ) > 0 {
112
- lowerKeyword := strings .ToLower (opts .Keyword )
113
- var keywordCond builder.Cond = builder.Like {"lower_name" , lowerKeyword }
114
- if opts .IncludeDesc {
115
- keywordCond = keywordCond .Or (builder.Like {"LOWER(description)" , lowerKeyword })
116
- }
117
- cond = cond .And (keywordCond )
118
- }
119
-
120
- if opts .OrgID > 0 {
121
- cond = cond .And (builder.Eq {"`team`.org_id" : opts .OrgID })
122
- }
123
-
124
- if opts .UserID > 0 {
125
- cond = cond .And (builder.Eq {"team_user.uid" : opts .UserID })
126
- }
127
-
128
- return cond
129
- }
130
-
131
- // SearchTeam search for teams. Caller is responsible to check permissions.
132
- func SearchTeam (opts * SearchTeamOptions ) ([]* Team , int64 , error ) {
133
- sess := db .GetEngine (db .DefaultContext )
134
-
135
- opts .SetDefaultValues ()
136
- cond := opts .toCond ()
137
-
138
- if opts .UserID > 0 {
139
- sess = sess .Join ("INNER" , "team_user" , "team_user.team_id = team.id" )
140
- }
141
- sess = db .SetSessionPagination (sess , opts )
142
-
143
- teams := make ([]* Team , 0 , opts .PageSize )
144
- count , err := sess .Where (cond ).OrderBy ("lower_name" ).FindAndCount (& teams )
145
- if err != nil {
146
- return nil , 0 , err
147
- }
148
-
149
- return teams , count , nil
150
- }
151
-
152
97
// ColorFormat provides a basic color format for a Team
153
98
func (t * Team ) ColorFormat (s fmt.State ) {
154
99
if t == nil {
@@ -335,16 +280,6 @@ func GetTeamNamesByID(teamIDs []int64) ([]string, error) {
335
280
return teamNames , err
336
281
}
337
282
338
- // GetRepoTeams gets the list of teams that has access to the repository
339
- func GetRepoTeams (ctx context.Context , repo * repo_model.Repository ) (teams []* Team , err error ) {
340
- return teams , db .GetEngine (ctx ).
341
- Join ("INNER" , "team_repo" , "team_repo.team_id = team.id" ).
342
- Where ("team.org_id = ?" , repo .OwnerID ).
343
- And ("team_repo.repo_id=?" , repo .ID ).
344
- OrderBy ("CASE WHEN name LIKE '" + OwnerTeamName + "' THEN '' ELSE name END" ).
345
- Find (& teams )
346
- }
347
-
348
283
// IncrTeamRepoNum increases the number of repos for the given team by 1
349
284
func IncrTeamRepoNum (ctx context.Context , teamID int64 ) error {
350
285
_ , err := db .GetEngine (ctx ).Incr ("num_repos" ).ID (teamID ).Update (new (Team ))
0 commit comments