Merge branch 'allow-filtering-labels-by-a-single-character' into 'master'
Allow filtering labels by a single character Closes #58795 See merge request gitlab-org/gitlab-ce!26012
This commit is contained in:
commit
69ed9ae4d4
4 changed files with 23 additions and 1 deletions
|
@ -126,6 +126,13 @@ 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 open_issues_count(user = nil)
|
||||
issues_count(user, state: 'opened')
|
||||
end
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Allow filtering labels list by one or two characters
|
||||
merge_request: 26012
|
||||
author:
|
||||
type: changed
|
|
@ -23,8 +23,12 @@ module Gitlab
|
|||
end
|
||||
end
|
||||
|
||||
def min_chars_for_partial_matching
|
||||
MIN_CHARS_FOR_PARTIAL_MATCHING
|
||||
end
|
||||
|
||||
def partial_matching?(query)
|
||||
query.length >= MIN_CHARS_FOR_PARTIAL_MATCHING
|
||||
query.length >= min_chars_for_partial_matching
|
||||
end
|
||||
|
||||
# column - The column name to search in.
|
||||
|
|
|
@ -209,6 +209,12 @@ describe LabelsFinder do
|
|||
|
||||
expect(finder.execute).to eq [project_label_1]
|
||||
end
|
||||
|
||||
it 'returns labels matching a single character' do
|
||||
finder = described_class.new(user, search: '(')
|
||||
|
||||
expect(finder.execute).to eq [group_label_1]
|
||||
end
|
||||
end
|
||||
|
||||
context 'filter by subscription' do
|
||||
|
|
Loading…
Reference in a new issue