diff options
author | Douwe Maan <douwe@gitlab.com> | 2015-10-14 12:33:39 +0200 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2015-10-14 12:33:39 +0200 |
commit | 3a69dd20a1d8e54c25f871f35f09a1b8b5d4b2a4 (patch) | |
tree | 8240d16965886c2a462fe969664de4e7d22b96e9 /app/services/labels | |
parent | 03b7fe71a5c5372fc8239a26e757685ab12eed87 (diff) | |
download | gitlab-ce-3a69dd20a1d8e54c25f871f35f09a1b8b5d4b2a4.tar.gz |
Allow dashboard and group issues/MRs to be filtered by label
Diffstat (limited to 'app/services/labels')
-rw-r--r-- | app/services/labels/group_service.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/app/services/labels/group_service.rb b/app/services/labels/group_service.rb new file mode 100644 index 00000000000..b26cee24d56 --- /dev/null +++ b/app/services/labels/group_service.rb @@ -0,0 +1,26 @@ +module Labels + class GroupService < ::BaseService + def initialize(project_labels) + @project_labels = project_labels.group_by(&:title) + end + + def execute + build(@project_labels) + end + + def label(title) + if title + group_label = @project_labels[title].group_by(&:title) + build(group_label).first + else + nil + end + end + + private + + def build(label) + label.map { |title, labels| GroupLabel.new(title, labels) } + end + end +end |