BigW Consortium Gitlab

global_milestones.rb 681 Bytes
Newer Older
1 2 3 4
module GlobalMilestones
  extend ActiveSupport::Concern

  def milestones
5
    epoch = DateTime.parse('1970-01-01')
6 7
    @milestones = MilestonesFinder.new.execute(@projects, params)
    @milestones = GlobalMilestone.build_collection(@milestones)
8
    @milestones = @milestones.sort_by { |x| x.due_date.nil? ? epoch : x.due_date }
9 10 11 12 13 14 15 16 17 18 19 20 21
    @milestones = Kaminari.paginate_array(@milestones).page(params[:page]).per(ApplicationController::PER_PAGE)
  end

  def milestone
    milestones = Milestone.of_projects(@projects).where(title: params[:title])

    if milestones.present?
      @milestone = GlobalMilestone.new(params[:title], milestones)
    else
      render_404
    end
  end
end