Skip to content

Commit 7bd8220

Browse files
committed
Add comments for the query conditions functions
1 parent 9bb54b2 commit 7bd8220

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

models/repo_list.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ func userMentionedRepoCond(id string, userID int64) builder.Cond {
227227
)
228228
}
229229

230+
// teamUnitsRepoCond returns query condition for those repo id in the special org team with special units access
230231
func teamUnitsRepoCond(id string, userID, orgID, teamID int64, units ...unit.Type) builder.Cond {
231232
return builder.In(id,
232233
builder.Select("repo_id").From("team_repo").Where(
@@ -253,7 +254,7 @@ func teamUnitsRepoCond(id string, userID, orgID, teamID int64, units ...unit.Typ
253254
))
254255
}
255256

256-
// userCollaborationRepoCond return user as collabrators repositories list
257+
// userCollaborationRepoCond returns user as collabrators repositories list
257258
func userCollaborationRepoCond(idStr string, userID int64) builder.Cond {
258259
return builder.In(idStr, builder.Select("repo_id").
259260
From("`access`").
@@ -264,30 +265,35 @@ func userCollaborationRepoCond(idStr string, userID int64) builder.Cond {
264265
)
265266
}
266267

268+
// userOrgTeamRepoCond selects repos that the given user has access to through team membership
267269
func userOrgTeamRepoCond(idStr string, userID int64) builder.Cond {
268270
return builder.In(idStr, userOrgTeamRepoBuilder(userID))
269271
}
270272

273+
// userOrgTeamRepoBuilder returns repo ids where user's teams can access.
271274
func userOrgTeamRepoBuilder(userID int64) *builder.Builder {
272275
return builder.Select("`team_repo`.repo_id").
273276
From("team_repo").
274277
Join("INNER", "team_user", "`team_user`.team_id = `team_repo`.team_id").
275278
Where(builder.Eq{"`team_user`.uid": userID})
276279
}
277280

281+
// userOrgTeamUnitRepoBuilder returns repo ids where user's teams can access the special unit.
278282
func userOrgTeamUnitRepoBuilder(userID int64, unitType unit.Type) *builder.Builder {
279283
return userOrgTeamRepoBuilder(userID).
280284
Join("INNER", "team_unit", "`team_unit`.team_id = `team_repo`.team_id").
281285
Where(builder.Eq{"`team_unit`.`type`": unitType})
282286
}
283287

288+
// userOrgUnitRepoCond selects repos that the given user has access to through org and the special unit
284289
func userOrgUnitRepoCond(idStr string, userID, orgID int64, unitType unit.Type) builder.Cond {
285290
return builder.In(idStr,
286291
userOrgTeamUnitRepoBuilder(userID, unitType).
287292
And(builder.Eq{"org_id": orgID}),
288293
)
289294
}
290295

296+
// userOrgPublicRepoCond returns the condition that one user could access all public repositories in organizations
291297
func userOrgPublicRepoCond(userID int64) builder.Cond {
292298
return builder.And(
293299
builder.Eq{"`repository`.is_private": false},
@@ -299,6 +305,7 @@ func userOrgPublicRepoCond(userID int64) builder.Cond {
299305
)
300306
}
301307

308+
// userOrgPublicRepoCondPrivate returns the condition that one user could access all public repositories in private organizations
302309
func userOrgPublicRepoCondPrivate(userID int64) builder.Cond {
303310
return builder.And(
304311
builder.Eq{"`repository`.is_private": false},
@@ -315,6 +322,7 @@ func userOrgPublicRepoCondPrivate(userID int64) builder.Cond {
315322
)
316323
}
317324

325+
// userOrgPublicUnitRepoCond returns the condition that one user could access all public repositories in the special organization
318326
func userOrgPublicUnitRepoCond(userID, orgID int64) builder.Cond {
319327
return userOrgPublicRepoCond(userID).
320328
And(builder.Eq{"`repository`.owner_id": orgID})

0 commit comments

Comments
 (0)