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:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2018-07-20 17:19:58 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2018-07-31 12:46:36 +0300
commitf42fe0b6370692afd8fe1a123dd136e2dd45d5dc (patch)
tree34de501fd74da1aedb87241198e7fb8d1240bf81 /app/models/label.rb
parent02e35a0d2630d6995652d67d32fb2462ae2f68b2 (diff)
Add ability to filter labels by title or description
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/models/label.rb')
-rw-r--r--app/models/label.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/app/models/label.rb b/app/models/label.rb
index 7bbcaa121ca..7b08547fa6e 100644
--- a/app/models/label.rb
+++ b/app/models/label.rb
@@ -2,6 +2,7 @@ class Label < ActiveRecord::Base
include CacheMarkdownField
include Referable
include Subscribable
+ include Gitlab::SQL::Pattern
# Represents a "No Label" state used for filtering Issues and Merge
# Requests that have no label assigned.
@@ -103,6 +104,17 @@ class Label < ActiveRecord::Base
nil
end
+ # Searches for labels with a matching title or description.
+ #
+ # This method uses ILIKE on PostgreSQL and LIKE on MySQL.
+ #
+ # query - The search query as a String.
+ #
+ # Returns an ActiveRecord::Relation.
+ def self.search(query)
+ fuzzy_search(query, [:title, :description])
+ end
+
def open_issues_count(user = nil)
issues_count(user, state: 'opened')
end