diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-07 18:07:50 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-07 18:07:50 +0000 |
commit | ec169c6384b44291551eb7998b4f7f1102a8af07 (patch) | |
tree | db35206559e536f354e53d71365054062f43b7fc /app | |
parent | f3597fc9f048f07e717ac4cb743a083b219f6258 (diff) | |
download | gitlab-ce-ec169c6384b44291551eb7998b4f7f1102a8af07.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/finders/group_projects_finder.rb | 14 | ||||
-rw-r--r-- | app/models/project.rb | 1 |
2 files changed, 15 insertions, 0 deletions
diff --git a/app/finders/group_projects_finder.rb b/app/finders/group_projects_finder.rb index 8ab5072fdc6..dd8b2f29425 100644 --- a/app/finders/group_projects_finder.rb +++ b/app/finders/group_projects_finder.rb @@ -11,6 +11,7 @@ # options: # only_owned: boolean # only_shared: boolean +# limit: integer # params: # sort: string # visibility_level: int @@ -20,6 +21,8 @@ # non_archived: boolean # class GroupProjectsFinder < ProjectsFinder + DEFAULT_PROJECTS_LIMIT = 100 + attr_reader :group, :options def initialize(group:, params: {}, options: {}, current_user: nil, project_ids_relation: nil) @@ -32,8 +35,19 @@ class GroupProjectsFinder < ProjectsFinder @options = options end + def execute + collection = super + limit(collection) + end + private + def limit(collection) + limit = options[:limit] + + limit.present? ? collection.with_limit(limit) : collection + end + def init_collection projects = if current_user collection_with_user diff --git a/app/models/project.rb b/app/models/project.rb index 301fcfc8c98..6ee300dc7f5 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -443,6 +443,7 @@ class Project < ApplicationRecord scope :with_merge_requests_available_for_user, ->(current_user) { with_feature_available_for_user(:merge_requests, current_user) } scope :with_merge_requests_enabled, -> { with_feature_enabled(:merge_requests) } scope :with_remote_mirrors, -> { joins(:remote_mirrors).where(remote_mirrors: { enabled: true }).distinct } + scope :with_limit, -> (maximum) { limit(maximum) } scope :with_group_runners_enabled, -> do joins(:ci_cd_settings) |