Commit 0291473b authored by tiagonbotelho's avatar tiagonbotelho

fixes issues

parent 7530827e
...@@ -245,7 +245,7 @@ class IssuableFinder ...@@ -245,7 +245,7 @@ class IssuableFinder
end end
def upcoming? def upcoming?
params[:milestone_title] == '#upcoming' && projects params[:milestone_title] == '#upcoming'
end end
def by_milestone(items) def by_milestone(items)
...@@ -253,7 +253,7 @@ class IssuableFinder ...@@ -253,7 +253,7 @@ class IssuableFinder
if filter_by_no_milestone? if filter_by_no_milestone?
items = items.where(milestone_id: [-1, nil]) items = items.where(milestone_id: [-1, nil])
elsif upcoming? elsif upcoming?
upcoming = Milestone.upcoming(projects) upcoming = Milestone.where(project_id: projects).upcoming
items = items.joins(:milestone).where(milestones: { title: upcoming.title }) items = items.joins(:milestone).where(milestones: { title: upcoming.title })
else else
items = items.joins(:milestone).where(milestones: { title: params[:milestone_title] }) items = items.joins(:milestone).where(milestones: { title: params[:milestone_title] })
......
...@@ -82,9 +82,8 @@ class Milestone < ActiveRecord::Base ...@@ -82,9 +82,8 @@ class Milestone < ActiveRecord::Base
super("milestones", /(?<milestone>\d+)/) super("milestones", /(?<milestone>\d+)/)
end end
def self.upcoming(projects) def self.upcoming
self.where(project_id: projects) self.where('due_date > ?', Time.now).order(due_date: :asc).first
.where('due_date > ?', Time.now). order(due_date: :asc).first
end end
def to_reference(from_project = nil) def to_reference(from_project = nil)
......
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