diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-07-01 07:18:15 +0000 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-07-01 07:18:15 +0000 |
commit | 8fb76a8308292d991a32ea76e50fb5ecfa3284b2 (patch) | |
tree | e874cb67947340fea027e94e7f5cae9e57d8d992 /app/services/milestones | |
parent | bcfcd243a635a1ce655440562897c3ef9603eda9 (diff) | |
parent | 3e52517da1c506885c06c13ff59ff5863bcb68ea (diff) | |
download | gitlab-ce-8fb76a8308292d991a32ea76e50fb5ecfa3284b2.tar.gz |
Merge branch 'group_milestones' into 'master'
Group milestones
Diffstat (limited to 'app/services/milestones')
-rw-r--r-- | app/services/milestones/group_service.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/app/services/milestones/group_service.rb b/app/services/milestones/group_service.rb new file mode 100644 index 00000000000..11d702f1e7b --- /dev/null +++ b/app/services/milestones/group_service.rb @@ -0,0 +1,26 @@ +module Milestones + class GroupService < Milestones::BaseService + def initialize(project_milestones) + @project_milestones = project_milestones.group_by(&:title) + end + + def execute + build(@project_milestones) + end + + def milestone(title) + if title + group_milestone = @project_milestones[title].group_by(&:title) + build(group_milestone).first + else + nil + end + end + + private + + def build(milestone) + milestone.map{ |title, milestones| GroupMilestone.new(title, milestones) } + end + end +end |