Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Lopez <james@jameslopez.es>2016-04-21 09:37:38 +0300
committerJames Lopez <james@jameslopez.es>2016-04-21 09:37:38 +0300
commit07f8ffbdaf2878fb97ae41a3e88ae5358e82dab7 (patch)
treeac822c75ae2448458dbee52edb611497e3c46d53 /app/finders
parent976593fa7fd657437c68ade72f2061260318e7a9 (diff)
parent2ade37e2534108c72d28605cb131dacf771d27d3 (diff)
Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce into fix/label-filters
# Conflicts: # spec/features/issues/filter_by_labels_spec.rb
Diffstat (limited to 'app/finders')
-rw-r--r--app/finders/issuable_finder.rb41
1 files changed, 40 insertions, 1 deletions
diff --git a/app/finders/issuable_finder.rb b/app/finders/issuable_finder.rb
index ca71acb65d3..93aa30b3255 100644
--- a/app/finders/issuable_finder.rb
+++ b/app/finders/issuable_finder.rb
@@ -39,6 +39,7 @@ class IssuableFinder
items = by_assignee(items)
items = by_author(items)
items = by_label(items)
+ items = by_due_date(items)
sort(items)
end
@@ -117,7 +118,7 @@ class IssuableFinder
end
def filter_by_no_label?
- labels? && params[:label_name] == Label::None.title
+ labels? && params[:label_name].include?(Label::None.title)
end
def labels
@@ -277,9 +278,47 @@ class IssuableFinder
end
end
+ # When filtering by multiple labels we may end up duplicating issues (if one
+ # has multiple labels). This ensures we only return unique issues.
+ items.distinct
+ end
+
+ def by_due_date(items)
+ if due_date?
+ if filter_by_no_due_date?
+ items = items.without_due_date
+ elsif filter_by_overdue?
+ items = items.due_before(Date.today)
+ elsif filter_by_due_this_week?
+ items = items.due_between(Date.today.beginning_of_week, Date.today.end_of_week)
+ elsif filter_by_due_this_month?
+ items = items.due_between(Date.today.beginning_of_month, Date.today.end_of_month)
+ end
+ end
+
items
end
+ def filter_by_no_due_date?
+ due_date? && params[:due_date] == Issue::NoDueDate.name
+ end
+
+ def filter_by_overdue?
+ due_date? && params[:due_date] == Issue::Overdue.name
+ end
+
+ def filter_by_due_this_week?
+ due_date? && params[:due_date] == Issue::DueThisWeek.name
+ end
+
+ def filter_by_due_this_month?
+ due_date? && params[:due_date] == Issue::DueThisMonth.name
+ end
+
+ def due_date?
+ params[:due_date].present? && klass.column_names.include?('due_date')
+ end
+
def label_names
params[:label_name].is_a?(String) ? params[:label_name].split(',') : params[:label_name]
end