@@ -106,11 +106,13 class Query < ActiveRecord::Base | |||
|
106 | 106 | "><" => :label_between, |
|
107 | 107 | "<t+" => :label_in_less_than, |
|
108 | 108 | ">t+" => :label_in_more_than, |
|
109 | "><t+"=> :label_in_the_next_days, | |
|
109 | 110 | "t+" => :label_in, |
|
110 | 111 | "t" => :label_today, |
|
111 | 112 | "w" => :label_this_week, |
|
112 | 113 | ">t-" => :label_less_than_ago, |
|
113 | 114 | "<t-" => :label_more_than_ago, |
|
115 | "><t-"=> :label_in_the_past_days, | |
|
114 | 116 | "t-" => :label_ago, |
|
115 | 117 | "~" => :label_contains, |
|
116 | 118 | "!~" => :label_not_contains, |
@@ -124,8 +126,8 class Query < ActiveRecord::Base | |||
|
124 | 126 | :list_status => [ "o", "=", "!", "c", "*" ], |
|
125 | 127 | :list_optional => [ "=", "!", "!*", "*" ], |
|
126 | 128 | :list_subprojects => [ "*", "!*", "=" ], |
|
127 | :date => [ "=", ">=", "<=", "><", "<t+", ">t+", "t+", "t", "w", ">t-", "<t-", "t-", "!*", "*" ], | |
|
128 | :date_past => [ "=", ">=", "<=", "><", ">t-", "<t-", "t-", "t", "w", "!*", "*" ], | |
|
129 | :date => [ "=", ">=", "<=", "><", "<t+", ">t+", "><t+", "t+", "t", "w", ">t-", "<t-", "><t-", "t-", "!*", "*" ], | |
|
130 | :date_past => [ "=", ">=", "<=", "><", ">t-", "<t-", "><t-", "t-", "t", "w", "!*", "*" ], | |
|
129 | 131 | :string => [ "=", "~", "!", "!~", "!*", "*" ], |
|
130 | 132 | :text => [ "~", "!~", "!*", "*" ], |
|
131 | 133 | :integer => [ "=", ">=", "<=", "><", "!*", "*" ], |
@@ -183,7 +185,7 class Query < ActiveRecord::Base | |||
|
183 | 185 | case operator_for(field) |
|
184 | 186 | when "=", ">=", "<=", "><" |
|
185 | 187 | 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?) } |
|
186 | when ">t-", "<t-", "t-", ">t+", "<t+", "t+" | |
|
188 | when ">t-", "<t-", "t-", ">t+", "<t+", "t+", "><t+", "><t-" | |
|
187 | 189 | add_filter_error(field, :invalid) if values_for(field).detect {|v| v.present? && !v.match(/^\d+$/) } |
|
188 | 190 | end |
|
189 | 191 | end |
@@ -936,21 +938,35 class Query < ActiveRecord::Base | |||
|
936 | 938 | sql = "#{Issue.table_name}.status_id IN (SELECT id FROM #{IssueStatus.table_name} WHERE is_closed=#{connection.quoted_false})" if field == "status_id" |
|
937 | 939 | when "c" |
|
938 | 940 | sql = "#{Issue.table_name}.status_id IN (SELECT id FROM #{IssueStatus.table_name} WHERE is_closed=#{connection.quoted_true})" if field == "status_id" |
|
939 | when ">t-" | |
|
941 | when "><t-" | |
|
942 | # between today - n days and today | |
|
940 | 943 | sql = relative_date_clause(db_table, db_field, - value.first.to_i, 0) |
|
944 | when ">t-" | |
|
945 | # >= today - n days | |
|
946 | sql = relative_date_clause(db_table, db_field, - value.first.to_i, nil) | |
|
941 | 947 | when "<t-" |
|
948 | # <= today - n days | |
|
942 | 949 | sql = relative_date_clause(db_table, db_field, nil, - value.first.to_i) |
|
943 | 950 | when "t-" |
|
951 | # = n days in past | |
|
944 | 952 | sql = relative_date_clause(db_table, db_field, - value.first.to_i, - value.first.to_i) |
|
953 | when "><t+" | |
|
954 | # between today and today + n days | |
|
955 | sql = relative_date_clause(db_table, db_field, 0, value.first.to_i) | |
|
945 | 956 | when ">t+" |
|
957 | # >= today + n days | |
|
946 | 958 | sql = relative_date_clause(db_table, db_field, value.first.to_i, nil) |
|
947 | 959 | when "<t+" |
|
948 | sql = relative_date_clause(db_table, db_field, 0, value.first.to_i) | |
|
960 | # <= today + n days | |
|
961 | sql = relative_date_clause(db_table, db_field, nil, value.first.to_i) | |
|
949 | 962 | when "t+" |
|
963 | # = today + n days | |
|
950 | 964 | sql = relative_date_clause(db_table, db_field, value.first.to_i, value.first.to_i) |
|
951 | 965 | when "t" |
|
966 | # = today | |
|
952 | 967 | sql = relative_date_clause(db_table, db_field, 0, 0) |
|
953 | 968 | when "w" |
|
969 | # = this week | |
|
954 | 970 | first_day_of_week = l(:general_first_day_of_week).to_i |
|
955 | 971 | day_of_week = Date.today.cwday |
|
956 | 972 | days_ago = (day_of_week >= first_day_of_week ? day_of_week - first_day_of_week : day_of_week + 7 - first_day_of_week) |
@@ -656,6 +656,8 en: | |||
|
656 | 656 | label_not_equals: is not |
|
657 | 657 | label_in_less_than: in less than |
|
658 | 658 | label_in_more_than: in more than |
|
659 | label_in_the_next_days: in the next | |
|
660 | label_in_the_past_days: in the past | |
|
659 | 661 | label_greater_or_equal: '>=' |
|
660 | 662 | label_less_or_equal: '<=' |
|
661 | 663 | label_between: between |
@@ -649,6 +649,8 fr: | |||
|
649 | 649 | label_not_equals: différent |
|
650 | 650 | label_in_less_than: dans moins de |
|
651 | 651 | label_in_more_than: dans plus de |
|
652 | label_in_the_next_days: dans les prochains jours | |
|
653 | label_in_the_past_days: dans les derniers jours | |
|
652 | 654 | label_in: dans |
|
653 | 655 | label_today: aujourd'hui |
|
654 | 656 | label_all_time: toute la période |
@@ -252,9 +252,11 function toggleOperator(field) { | |||
|
252 | 252 | break; |
|
253 | 253 | case "<t+": |
|
254 | 254 | case ">t+": |
|
255 | case "><t+": | |
|
255 | 256 | case "t+": |
|
256 | 257 | case ">t-": |
|
257 | 258 | case "<t-": |
|
259 | case "><t-": | |
|
258 | 260 | case "t-": |
|
259 | 261 | enableValues(field, [2]); |
|
260 | 262 | break; |
@@ -413,6 +413,14 class QueryTest < ActiveSupport::TestCase | |||
|
413 | 413 | query.add_filter('due_date', '<t+', ['15']) |
|
414 | 414 | issues = find_issues_with_query(query) |
|
415 | 415 | assert !issues.empty? |
|
416 | issues.each {|issue| assert(issue.due_date <= (Date.today + 15))} | |
|
417 | end | |
|
418 | ||
|
419 | def test_operator_in_the_next_days | |
|
420 | query = Query.new(:project => Project.find(1), :name => '_') | |
|
421 | query.add_filter('due_date', '><t+', ['15']) | |
|
422 | issues = find_issues_with_query(query) | |
|
423 | assert !issues.empty? | |
|
416 | 424 | issues.each {|issue| assert(issue.due_date >= Date.today && issue.due_date <= (Date.today + 15))} |
|
417 | 425 | end |
|
418 | 426 | |
@@ -422,6 +430,15 class QueryTest < ActiveSupport::TestCase | |||
|
422 | 430 | query.add_filter('due_date', '>t-', ['3']) |
|
423 | 431 | issues = find_issues_with_query(query) |
|
424 | 432 | assert !issues.empty? |
|
433 | issues.each {|issue| assert(issue.due_date >= (Date.today - 3))} | |
|
434 | end | |
|
435 | ||
|
436 | def test_operator_in_the_past_days | |
|
437 | Issue.find(7).update_attribute(:due_date, (Date.today - 3)) | |
|
438 | query = Query.new(:project => Project.find(1), :name => '_') | |
|
439 | query.add_filter('due_date', '><t-', ['3']) | |
|
440 | issues = find_issues_with_query(query) | |
|
441 | assert !issues.empty? | |
|
425 | 442 | issues.each {|issue| assert(issue.due_date >= (Date.today - 3) && issue.due_date <= Date.today)} |
|
426 | 443 | end |
|
427 | 444 |
General Comments 0
You need to be logged in to leave comments.
Login now