summaryrefslogtreecommitdiff
path: root/app/models/label.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/label.rb')
-rw-r--r--app/models/label.rb18
1 files changed, 17 insertions, 1 deletions
diff --git a/app/models/label.rb b/app/models/label.rb
index 1c3db3eb35d..e9085e8bd25 100644
--- a/app/models/label.rb
+++ b/app/models/label.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-class Label < ActiveRecord::Base
+class Label < ApplicationRecord
include CacheMarkdownField
include Referable
include Subscribable
@@ -8,6 +8,7 @@ class Label < ActiveRecord::Base
include OptionallySearch
include Sortable
include FromUnion
+ include Presentable
cache_markdown_field :description, pipeline: :single_line
@@ -126,6 +127,17 @@ class Label < ActiveRecord::Base
fuzzy_search(query, [:title, :description])
end
+ # Override Gitlab::SQL::Pattern.min_chars_for_partial_matching as
+ # label queries are never global, and so will not use a trigram
+ # index. That means we can have just one character in the LIKE.
+ def self.min_chars_for_partial_matching
+ 1
+ end
+
+ def self.by_ids(ids)
+ where(id: ids)
+ end
+
def open_issues_count(user = nil)
issues_count(user, state: 'opened')
end
@@ -222,6 +234,10 @@ class Label < ActiveRecord::Base
attributes
end
+ def present(attributes)
+ super(attributes.merge(presenter_class: ::LabelPresenter))
+ end
+
private
def issues_count(user, params = {})