diff options
author | Maxim Rydkin <maks.rydkin@gmail.com> | 2017-07-24 10:54:16 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-07-24 10:54:16 +0000 |
commit | fab1b0f1d189094ade6be5c35f03a53eeff99872 (patch) | |
tree | 0fd0e43232447b1915227088fe4152753bae93f1 /app/finders | |
parent | 56977be31ad37945863a08169bc72c679a294ea0 (diff) | |
download | gitlab-ce-fab1b0f1d189094ade6be5c35f03a53eeff99872.tar.gz |
Decrease ABC threshold to 56.96
Diffstat (limited to 'app/finders')
-rw-r--r-- | app/finders/admin/projects_finder.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/app/finders/admin/projects_finder.rb b/app/finders/admin/projects_finder.rb new file mode 100644 index 00000000000..a5ba791a513 --- /dev/null +++ b/app/finders/admin/projects_finder.rb @@ -0,0 +1,33 @@ +class Admin::ProjectsFinder + attr_reader :sort, :namespace_id, :visibility_level, :with_push, + :abandoned, :last_repository_check_failed, :archived, + :personal, :name, :page, :current_user + + def initialize(params:, current_user:) + @current_user = current_user + @sort = params.fetch(:sort) { 'latest_activity_desc' } + @namespace_id = params[:namespace_id] + @visibility_level = params[:visibility_level] + @with_push = params[:with_push] + @abandoned = params[:abandoned] + @last_repository_check_failed = params[:last_repository_check_failed] + @archived = params[:archived] + @personal = params[:personal] + @name = params[:name] + @page = params[:page] + end + + def execute + items = Project.with_statistics + items = items.in_namespace(namespace_id) if namespace_id.present? + items = items.where(visibility_level: visibility_level) if visibility_level.present? + items = items.with_push if with_push.present? + items = items.abandoned if abandoned.present? + items = items.where(last_repository_check_failed: true) if last_repository_check_failed.present? + items = items.non_archived unless archived.present? + items = items.personal(current_user) if personal.present? + items = items.search(name) if name.present? + items = items.sort(sort) + items.includes(:namespace).order("namespaces.path, projects.name ASC").page(page) + end +end |