@@ -61,25 +61,25 @@ def authorized_snippets
61
61
# Returns a collection of projects that is either public or visible to the
62
62
# logged in user.
63
63
#
64
- # A caller may pass in a block to modify individual parts of
64
+ # A caller must pass in a block to modify individual parts of
65
65
# the query, e.g. to apply .with_feature_available_for_user on top of it.
66
66
# This is useful for performance as we can stick those additional filters
67
67
# at the bottom of e.g. the UNION.
68
- def projects_for_user ( & block )
69
- return block . call ( Project . public_to_user ) unless current_user
68
+ def projects_for_user
69
+ return yield ( Project . public_to_user ) unless current_user
70
70
71
71
# If the current_user is allowed to see all projects,
72
72
# we can shortcut and just return.
73
- return block . call ( Project . all ) if current_user . full_private_access?
73
+ return yield ( Project . all ) if current_user . full_private_access?
74
74
75
75
authorized = current_user
76
76
. project_authorizations
77
77
. select ( 1 )
78
78
. where ( 'project_authorizations.project_id = projects.id' )
79
- authorized_projects = block . call ( Project . where ( 'EXISTS (?)' , authorized ) )
79
+ authorized_projects = yield ( Project . where ( 'EXISTS (?)' , authorized ) )
80
80
81
81
levels = Gitlab ::VisibilityLevel . levels_for_user ( current_user )
82
- visible_projects = block . call ( Project . where ( visibility_level : levels ) )
82
+ visible_projects = yield ( Project . where ( visibility_level : levels ) )
83
83
84
84
# We use a UNION here instead of OR clauses since this results in better
85
85
# performance.
0 commit comments