From d62ef6b9b1dcc64ac80b6c79797d6b6ce33e50cc Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Tue, 30 Oct 2012 08:21:15 +0000 Subject: Changes how relative date filters work and adds specific filters for filtering dates in past/next n days (#11426). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10768 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/query.rb | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'app') diff --git a/app/models/query.rb b/app/models/query.rb index b5c932cfa..0f6ae3a1d 100644 --- a/app/models/query.rb +++ b/app/models/query.rb @@ -106,11 +106,13 @@ class Query < ActiveRecord::Base "><" => :label_between, " :label_in_less_than, ">t+" => :label_in_more_than, + "> :label_in_the_next_days, "t+" => :label_in, "t" => :label_today, "w" => :label_this_week, ">t-" => :label_less_than_ago, " :label_more_than_ago, + "> :label_in_the_past_days, "t-" => :label_ago, "~" => :label_contains, "!~" => :label_not_contains, @@ -124,8 +126,8 @@ class Query < ActiveRecord::Base :list_status => [ "o", "=", "!", "c", "*" ], :list_optional => [ "=", "!", "!*", "*" ], :list_subprojects => [ "*", "!*", "=" ], - :date => [ "=", ">=", "<=", "><", "t+", "t+", "t", "w", ">t-", " [ "=", ">=", "<=", "><", ">t-", " [ "=", ">=", "<=", "><", "t+", ">t-", " [ "=", ">=", "<=", "><", ">t-", " [ "=", "~", "!", "!~", "!*", "*" ], :text => [ "~", "!~", "!*", "*" ], :integer => [ "=", ">=", "<=", "><", "!*", "*" ], @@ -183,7 +185,7 @@ class Query < ActiveRecord::Base case operator_for(field) when "=", ">=", "<=", "><" add_filter_error(field, :invalid) if values_for(field).detect {|v| v.present? && (!v.match(/^\d{4}-\d{2}-\d{2}$/) || (Date.parse(v) rescue nil).nil?) } - when ">t-", "t+", "t-", "t+", "t-" + when ">t-" + # >= today - n days + sql = relative_date_clause(db_table, db_field, - value.first.to_i, nil) when "t+" + # >= today + n days sql = relative_date_clause(db_table, db_field, value.first.to_i, nil) when "= first_day_of_week ? day_of_week - first_day_of_week : day_of_week + 7 - first_day_of_week) -- cgit v1.2.3