Project

General

Profile

Actions

Patch #4502

closed

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

Added by Andrew Chaika over 14 years ago. Updated about 5 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Issues filter
Target version:
Start date:
2009-12-29
Due date:
% Done:

0%

Estimated time:

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

Related to Redmine - Feature #4729: Add Date-Based Filters for Issues ListClosed2010-02-03

Actions
Related to Redmine - Feature #6954: Filter from date to dateClosed2010-11-22

Actions
Related to Redmine - Patch #18868: Add support for queries with 'next week' filterClosed

Actions
Actions #1

Updated by Александр Курутин over 6 years ago

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

Actions #2

Updated by Sebastian Paluch almost 6 years ago

+1

Actions #3

Updated by Go MAEDA almost 6 years ago

  • Category set to Issues filter
Actions #4

Updated by Go MAEDA over 5 years ago

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

Updated by Go MAEDA over 5 years ago

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.

Actions #6

Updated by Mizuki ISHIKAWA over 5 years ago

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.

Actions #7

Updated by Mizuki ISHIKAWA over 5 years ago

I fixed patch because unnecessary tests were included.

Actions #8

Updated by Marius BĂLTEANU over 5 years ago

  • Target version set to Candidate for next major release

LGTM

Actions #9

Updated by Go MAEDA over 5 years ago

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-", "!*", "*" ],

Actions #10

Updated by Go MAEDA about 5 years ago

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

Updated by Go MAEDA about 5 years ago

  • 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.

Actions #12

Updated by Go MAEDA about 5 years ago

  • 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
Actions #13

Updated by Go MAEDA about 5 years ago

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
Actions #14

Updated by Mizuki ISHIKAWA about 5 years ago

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.

Actions #15

Updated by Go MAEDA about 5 years ago

  • Status changed from Reopened to Closed
Actions

Also available in: Atom PDF