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:
Diffstat (limited to 'app/models/namespace.rb')
-rw-r--r--app/models/namespace.rb16
1 files changed, 13 insertions, 3 deletions
diff --git a/app/models/namespace.rb b/app/models/namespace.rb
index 7c6fa24cd4d..7b3bb04da5b 100644
--- a/app/models/namespace.rb
+++ b/app/models/namespace.rb
@@ -229,11 +229,15 @@ class Namespace < ApplicationRecord
# query - The search query as a String.
#
# Returns an ActiveRecord::Relation.
- def search(query, include_parents: false)
+ def search(query, include_parents: false, use_minimum_char_limit: true)
if include_parents
- without_project_namespaces.where(id: Route.for_routable_type(Namespace.name).fuzzy_search(query, [Route.arel_table[:path], Route.arel_table[:name]]).select(:source_id))
+ without_project_namespaces
+ .where(id: Route.for_routable_type(Namespace.name)
+ .fuzzy_search(query, [Route.arel_table[:path], Route.arel_table[:name]],
+ use_minimum_char_limit: use_minimum_char_limit)
+ .select(:source_id))
else
- without_project_namespaces.fuzzy_search(query, [:path, :name])
+ without_project_namespaces.fuzzy_search(query, [:path, :name], use_minimum_char_limit: use_minimum_char_limit)
end
end
@@ -400,6 +404,12 @@ class Namespace < ApplicationRecord
Project.where(namespace: namespace)
end
+ # Includes projects from this namespace and projects from all subgroups
+ # that belongs to this namespace, except the ones that are soft deleted
+ def all_projects_except_soft_deleted
+ all_projects.not_aimed_for_deletion
+ end
+
def has_parent?
parent_id.present? || parent.present?
end