gitlab-org--gitlab-foss/app/models/dashboard_group_milestone.rb
Douglas Barbosa Alexandre ec14d3fe34
Don't use MilestoneFinder for group milestones
This refactors the DashboardGroupMilestone model so that it no
longer uses the MilestoneFinder, instead using methods defined
on the Milestone model directly.
2018-09-18 11:35:21 -03:00

40 lines
907 B
Ruby

# frozen_string_literal: true
# Dashboard Group Milestones are milestones that allow us to pull more info out for the UI that the Milestone object doesn't allow for
class DashboardGroupMilestone < GlobalMilestone
extend ::Gitlab::Utils::Override
attr_reader :group_name
override :initialize
def initialize(milestone)
super(milestone.title, Array(milestone))
@group_name = milestone.group.full_name
end
def self.build_collection(groups)
Milestone.of_groups(groups.select(:id))
.reorder_by_due_date_asc
.order_by_name_asc
.active
.map { |m| new(m) }
end
override :group_milestone?
def group_milestone?
@first_milestone.group_milestone?
end
override :milestoneish_ids
def milestoneish_ids
milestones.map(&:id)
end
def group
@first_milestone.group
end
def iid
@first_milestone.iid
end
end