Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-01-24 21:11:44 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-01-24 21:11:44 +0300
commitfd247970cfe1e98276c780fbdcca026b7960e42a (patch)
treeab7963eb9b30fd73283c526cb6ae4ca1ef61c06f /app/finders
parentdf9890e9a702e2f12bbc8f022b916ca72820a292 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/finders')
-rw-r--r--app/finders/namespaces/projects_finder.rb30
-rw-r--r--app/finders/projects_finder.rb23
2 files changed, 39 insertions, 14 deletions
diff --git a/app/finders/namespaces/projects_finder.rb b/app/finders/namespaces/projects_finder.rb
index 589a9696ea6..c96f9527dd8 100644
--- a/app/finders/namespaces/projects_finder.rb
+++ b/app/finders/namespaces/projects_finder.rb
@@ -12,6 +12,8 @@
# search: string
# include_subgroups: boolean
# ids: int[]
+# with_issues_enabled: boolean
+# with_merge_requests_enabled: boolean
#
module Namespaces
class ProjectsFinder
@@ -30,7 +32,9 @@ module Namespaces
namespace.projects.with_route
end
- filter_projects(collection)
+ collection = filter_projects(collection)
+
+ sort(collection)
end
private
@@ -39,7 +43,8 @@ module Namespaces
def filter_projects(collection)
collection = by_ids(collection)
- by_similarity(collection)
+ collection = by_similarity(collection)
+ by_feature_availability(collection)
end
def by_ids(items)
@@ -51,11 +56,26 @@ module Namespaces
def by_similarity(items)
return items unless params[:search].present?
- if params[:sort] == :similarity
- items = items.sorted_by_similarity_desc(params[:search], include_in_select: true)
+ items.merge(Project.search(params[:search]))
+ end
+
+ def by_feature_availability(items)
+ items = items.with_issues_available_for_user(current_user) if params[:with_issues_enabled].present?
+ if params[:with_merge_requests_enabled].present?
+ items = items.with_merge_requests_available_for_user(current_user)
end
- items.merge(Project.search(params[:search]))
+ items
+ end
+
+ def sort(items)
+ return items.projects_order_id_desc unless params[:sort]
+
+ if params[:sort] == :similarity && params[:search].present?
+ return items.sorted_by_similarity_desc(params[:search], include_in_select: true)
+ end
+
+ items.sort_by_attribute(params[:sort])
end
end
end
diff --git a/app/finders/projects_finder.rb b/app/finders/projects_finder.rb
index 1afd5adeada..7226a4c0d82 100644
--- a/app/finders/projects_finder.rb
+++ b/app/finders/projects_finder.rb
@@ -56,11 +56,7 @@ class ProjectsFinder < UnionFinder
collection = Project.wrap_with_cte(collection) if use_cte
collection = filter_projects(collection)
- if params[:sort] == 'similarity' && params[:search]
- collection.sorted_by_similarity_desc(params[:search])
- else
- sort(collection)
- end
+ sort(collection)
end
private
@@ -90,6 +86,7 @@ class ProjectsFinder < UnionFinder
collection = by_last_activity_after(collection)
collection = by_last_activity_before(collection)
collection = by_language(collection)
+ collection = by_feature_availability(collection)
by_repository_storage(collection)
end
@@ -247,11 +244,13 @@ class ProjectsFinder < UnionFinder
end
def sort(items)
- if params[:sort].present?
- items.sort_by_attribute(params[:sort])
- else
- items.projects_order_id_desc
+ return items.projects_order_id_desc unless params[:sort]
+
+ if params[:sort] == 'similarity' && params[:search].present?
+ return items.sorted_by_similarity_desc(params[:search], include_in_select: true)
end
+
+ items.sort_by_attribute(params[:sort])
end
def by_archived(projects)
@@ -270,6 +269,12 @@ class ProjectsFinder < UnionFinder
end
end
+ def by_feature_availability(items)
+ items = items.with_issues_available_for_user(current_user) if params[:with_issues_enabled]
+ items = items.with_merge_requests_available_for_user(current_user) if params[:with_merge_requests_enabled]
+ items
+ end
+
def finder_params
return {} unless min_access_level?