It's currently impossible to set a date filter that is more granular than just seconds. This makes it impossible to use views query cache.

CommentFileSizeAuthor
#2 2825775-2.patch822 bytescasey

Comments

casey created an issue. See original summary.

casey’s picture

Status: Active » Needs review
StatusFileSize
new822 bytes

This use a similar approach as \Drupal\datetime\Plugin\views\filter\Date::opSimple().

Now we can use date filters with type offset with values like "today - 1 month"

othermachines’s picture

Patch in #2 tested and seems to work well. Here's my output:

-----

[min] => 
[max] => 
[value] => today - 2 weeks
[type] => offset

Before patch:

// Prints Tue, 28 Mar 2017 13:48:11 -0600
dpm(date('r', REQUEST_TIME));

// Prints Mon, 13 Mar 2017 20:48:11 -0600
dpm(date('r', $value));

After:

// Prints Tue, 28 Mar 2017 13:49:24 -0600
dpm(date('r', REQUEST_TIME));

// Prints Tue, 14 Mar 2017 00:00:00 -0600
dpm(date('r', $value));


-----

[min] => 
[max] => 
[value] => today - 2 weeks 2 hours 2 seconds
[type] => offset

Before patch:

// Prints Tue, 28 Mar 2017 13:50:12 -0600
dpm(date('r', REQUEST_TIME));

// Prints Mon, 13 Mar 2017 22:50:14 -0600
dpm(date('r', $value));

After:

// Prints Tue, 28 Mar 2017 13:50:49 -0600
dpm(date('r', REQUEST_TIME));

// Prints Tue, 14 Mar 2017 02:00:02 -0600
dpm(date('r', $value));


-----

[min] => 
[max] => 
[value] => -2 weeks
[type] => offset

No difference.

google_analytics_reports 8.x-3.x-dev
Drupal 8.2.7

esolitos’s picture

Status: Needs review » Reviewed & tested by the community

I've been using this patch in production for several months, no issue encountered.

rajab natshah’s picture

Committed ... Thank you :)

rajab natshah’s picture

rajab natshah’s picture

Title: Cannot set granular date filter » Fix to set granular date filter
rajab natshah’s picture

Assigned: Unassigned » mohammed j. razem
Status: Reviewed & tested by the community » Needs review
rajab natshah’s picture

Assigned: mohammed j. razem » Unassigned
rajab natshah’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.