BigW Consortium Gitlab

Commit b9d13c11 by tiagonbotelho

implements upcoming filter in milstones

parent 5a586f36
......@@ -94,6 +94,10 @@ class IssuableFinder
params[:milestone_title].present?
end
def upcoming?
params[:milestone_title] == 'Upcoming'
end
def filter_by_no_milestone?
milestones? && params[:milestone_title] == Milestone::None.title
end
......@@ -248,6 +252,10 @@ class IssuableFinder
if milestones?
if filter_by_no_milestone?
items = items.where(milestone_id: [-1, nil])
elsif upcoming?
upcoming = Milestone.where(project_id: projects)
.where('due_date > ?', Time.now).order(due_date: :asc).first
items = items.joins(:milestone).where(milestone: { title: upcoming.title })
else
items = items.joins(:milestone).where(milestones: { title: params[:milestone_title] })
......
......@@ -59,6 +59,7 @@ module MilestonesHelper
grouped_milestones = grouped_milestones.sort_by { |x| x.due_date.nil? ? epoch : x.due_date }
grouped_milestones.unshift(Milestone::None)
grouped_milestones.unshift(Milestone::Any)
grouped_milestones.unshift(Milestone::Upcoming)
options_from_collection_for_select(grouped_milestones, 'name', 'title', params[:milestone_title])
end
......
......@@ -19,6 +19,7 @@ class Milestone < ActiveRecord::Base
MilestoneStruct = Struct.new(:title, :name, :id)
None = MilestoneStruct.new('No Milestone', 'No Milestone', 0)
Any = MilestoneStruct.new('Any Milestone', '', -1)
Upcoming = MilestoneStruct.new('Upcoming', '', -2)
include InternalId
include Sortable
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment