Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tatuya Kamada
gitlab-ce
Commits
d3b76e83
Commit
d3b76e83
authored
Oct 17, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reuse LabelsFinder on Banzai::Filter::LabelReferenceFilter
parent
1e5ea6e7
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
11 deletions
+15
-11
app/finders/labels_finder.rb
app/finders/labels_finder.rb
+14
-4
lib/banzai/filter/label_reference_filter.rb
lib/banzai/filter/label_reference_filter.rb
+1
-7
No files found.
app/finders/labels_finder.rb
View file @
d3b76e83
...
...
@@ -4,7 +4,9 @@ class LabelsFinder < UnionFinder
@params
=
params
end
def
execute
def
execute
(
authorized_only:
true
)
@authorized_only
=
authorized_only
items
=
find_union
(
label_ids
,
Label
)
items
=
with_title
(
items
)
sort
(
items
)
...
...
@@ -12,7 +14,7 @@ class LabelsFinder < UnionFinder
private
attr_reader
:current_user
,
:params
attr_reader
:current_user
,
:params
,
:authorized_only
def
label_ids
label_ids
=
[]
...
...
@@ -57,7 +59,7 @@ class LabelsFinder < UnionFinder
return
@project
if
defined?
(
@project
)
if
project_id
@project
=
available_projects
.
find
(
project_id
)
rescue
nil
@project
=
find_project
else
@project
=
nil
end
...
...
@@ -65,10 +67,18 @@ class LabelsFinder < UnionFinder
@project
end
def
find_project
if
authorized_only
available_projects
.
find_by
(
id:
project_id
)
else
Project
.
find_by
(
id:
project_id
)
end
end
def
projects
return
@projects
if
defined?
(
@projects
)
@projects
=
a
vailable_projects
@projects
=
a
uthorized_only
?
available_projects
:
Project
.
all
@projects
=
@projects
.
in_namespace
(
group_id
)
if
group_id
@projects
=
@projects
.
where
(
id:
projects_ids
)
if
projects_ids
@projects
=
@projects
.
reorder
(
nil
)
...
...
lib/banzai/filter/label_reference_filter.rb
View file @
d3b76e83
...
...
@@ -39,13 +39,7 @@ module Banzai
end
def
find_labels
(
project
)
label_ids
=
[]
label_ids
<<
project
.
group
.
labels
.
select
(
:id
)
if
project
.
group
.
present?
label_ids
<<
project
.
labels
.
select
(
:id
)
union
=
Gitlab
::
SQL
::
Union
.
new
(
label_ids
)
Label
.
where
(
"labels.id IN (
#{
union
.
to_sql
}
)"
)
LabelsFinder
.
new
(
nil
,
project_id:
project
.
id
).
execute
(
authorized_only:
false
)
end
# Parameters to pass to `Label.find_by` based on the given arguments
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment