Project

General

Profile

Actions

Patch #4502

closed

New date filter operators: tomorrow, next week, next month

Patch #4502: New date filter operators: tomorrow, next week, next month

Added by Andrew Chaika almost 17 years ago. Updated over 7 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Issues filter
Target version:

Description

For my work there is need to have a plan for the next month and report for the last. I have implemented this in Redmine by using additional filter options on date fields - last month, next month, this month. Patch attached.
Maybe we can integrate this functionality into the trunk?


Files

query_months_filters.patch (3.8 KB) query_months_filters.patch Andrew Chaika, 2009-12-29 09:48
add-next-range-filters.patch (7.18 KB) add-next-range-filters.patch Mizuki ISHIKAWA, 2019-01-10 01:48
add-next-range-filters-v2.patch (6.85 KB) add-next-range-filters-v2.patch Mizuki ISHIKAWA, 2019-01-10 02:40
operators@2x.png (48.3 KB) operators@2x.png Go MAEDA, 2019-01-13 05:29
fix_test.patch (910 Bytes) fix_test.patch Mizuki ISHIKAWA, 2019-03-05 03:17

Related issues 3 (0 open — 3 closed)

Related to Redmine - Feature #4729: Add Date-Based Filters for Issues ListClosedActions
Related to Redmine - Feature #6954: Filter from date to dateClosedActions
Related to Redmine - Patch #18868: Add support for queries with 'next week' filterClosedActions

Updated by Александр Курутин about 9 years ago Actions #1

7 years have passed, but there is still no filter (next month).

Updated by Sebastian Paluch over 8 years ago Actions #2

+1

Updated by Go MAEDA over 8 years ago Actions #3

  • Category set to Issues filter

Updated by Go MAEDA almost 8 years ago Actions #4

  • Related to Patch #18868: Add support for queries with 'next week' filter added

Updated by Go MAEDA almost 8 years ago Actions #5

Redmine 4.0.0 has "yesterday", "last week", and "last month" filter but does not "tomorrow", "next week", and "next month" filter.

I think those filters should be useful for many users.

Updated by Mizuki ISHIKAWA almost 8 years ago Actions #6

Go MAEDA wrote:

Redmine 4.0.0 has "yesterday", "last week", and "last month" filter but does not "tomorrow", "next week", and "next month" filter.

I think those filters should be useful for many users.

I wrote a patch to add "tomorrow", "next week", and "next month" filter.
It is useful to have this filter when checking the tasks to be executed next month, next week, tomorrow.

Updated by Mizuki ISHIKAWA almost 8 years ago Actions #7

I fixed patch because unnecessary tests were included.

Updated by Marius BĂLTEANU almost 8 years ago Actions #8

  • Target version set to Candidate for next major release

LGTM

Updated by Go MAEDA almost 8 years ago Actions #9

Setting the target version to 4.1.0.

I propose reordering the operators as follows. While the current patch shows operators in "present -> past -> future" order, my change shows operators in "future -> present -> past" order. For example, operators will be ordered like "tomorrow, today, yesterday" and "next week, this week, last week, last 2 weeks" instead of "today, yesterday, tomorrow" and "this week, last week, last 2 weeks, next week". The proposing order is a tidy reverse-chronological order and should be intuitive.

    :date => [ "=", ">=", "<=", "><", "<t+", ">t+", "><t+", "t+", "nd", "t", "ld", "nw", "w", "lw", "l2w", "nm", "m", "lm", "y", ">t-", "<t-", "><t-", "t-", "!*", "*" ],

Updated by Go MAEDA almost 8 years ago Actions #10

  • Subject changed from Query date filters by months (prev, this, next) to New date filter operators: tomorrow, next week, next month

Updated by Go MAEDA almost 8 years ago Actions #11

  • Status changed from New to Closed
  • Assignee set to Go MAEDA

Committed the patch. Thank you for improving Redmine.

I changed the order or operators and added Japanese translation.

Updated by Go MAEDA almost 8 years ago Actions #12

  • Status changed from Closed to Reopened

QueryTest#test_operator_tomorrow fails depending on timezone.

I could reproduce the problem at 22:21 HST (Hawaii Standard Time -1000, 08:21 UTC). Maybe the problem occurs if the local date is different from the UTC date.

$ date
Fri Jan 18 22:21:34 HST 2019
$ ruby test/unit/query_test.rb
Run options: --seed 35057

# Running:

.................................................................................................................F

Failure:
QueryTest#test_operator_tomorrow [test/unit/query_test.rb:645]:
Expected false to be truthy.

bin/rails test test/unit/query_test.rb:641

...............................................................................................

Finished in 22.371776s, 9.3421 runs/s, 26.4619 assertions/s.
209 runs, 592 assertions, 1 failures, 0 errors, 0 skips

Updated by Go MAEDA almost 8 years ago Actions #13

The current date of my PC is 2019-01-18 HST (2019-01-19 UTC).

QueryTest#test_operator_tomorrow expects that there are some issues whose due date is tomorrow (2019-01-19). However, there are issues whose due date is the day after the tomorrow (2019-01-20).

sqlite> select id, due_date from issues;
id          due_date
----------  ----------
1           2019-01-29
2
3           2019-01-14
4
5
6           2019-01-20
7           2019-01-18
8
9           2019-01-20
10          2019-01-20
11
12
13
14

Probably the reason is that the timezone of fixtures is UTC. 1.days.from_now.to_date.to_s(:db) returns a date in UTC (2019-01-20), while the test code expects 2019-01-19 that is the date of tomorrow in the local time (the current date of the local time is still 2019-01-18 HST).

issues_006:
  created_on: <%= 1.minute.ago.to_s(:db) %>
  project_id: 5
  updated_on: <%= 1.minute.ago.to_s(:db) %>
  priority_id: 4
  subject: Issue of a private subproject
  id: 6
  fixed_version_id:
  category_id:
  description: This is an issue of a private subproject of cookbook
  tracker_id: 1
  assigned_to_id:
  author_id: 2
  status_id: 1
  start_date: <%= Date.today.to_s(:db) %>
  due_date: <%= 1.days.from_now.to_date.to_s(:db) %>
  root_id: 6
  lft: 1
  rgt: 2

The date of fixtures are UTC, I think we have to run the test in UTC. The following workaround resolves the failing test.

Index: test/unit/query_test.rb
===================================================================
--- test/unit/query_test.rb    (revision 17811)
+++ test/unit/query_test.rb    (working copy)
@@ -639,11 +639,13 @@
   end

   def test_operator_tomorrow
+    User.current = User.find_by_login('admin')
+    User.current.pref.update_attribute :time_zone, 'UTC'
     query = IssueQuery.new(:project => Project.find(1), :name => '_')
     query.add_filter('due_date', 'nd', [''])
     issues = find_issues_with_query(query)
     assert !issues.empty?
-    issues.each {|issue| assert_equal Date.today.tomorrow, issue.due_date}
+    issues.each {|issue| assert_equal User.current.today.tomorrow, issue.due_date}
   end

   def test_operator_date_periods

Updated by Mizuki ISHIKAWA over 7 years ago Actions #14

Go MAEDA wrote:

QueryTest#test_operator_tomorrow fails depending on timezone.

I could reproduce the problem at 22:21 HST (Hawaii Standard Time -1000, 08:21 UTC). Maybe the problem occurs if the local date is different from the UTC date.

Thank you for pointing that out.

The attached patch updates the #4502#note-13 test to fix the random failure.

Updated by Go MAEDA over 7 years ago Actions #15

  • Status changed from Reopened to Closed
Actions

Also available in: PDF Atom