Merge lp:~dkessel/ubuntu-qa-website/fix-end-date-of-date-range-queries into lp:ubuntu-qa-website

Proposed by Daniel Kessel
Status: Merged
Approved by: Nicholas Skaggs
Approved revision: 405
Merged at revision: 405
Proposed branch: lp:~dkessel/ubuntu-qa-website/fix-end-date-of-date-range-queries
Merge into: lp:ubuntu-qa-website
Diff against target: 13 lines (+2/-1)
1 file modified
modules/qatracker/report/qatracker.report.testers.php (+2/-1)
To merge this branch: bzr merge lp:~dkessel/ubuntu-qa-website/fix-end-date-of-date-range-queries
Reviewer Review Type Date Requested Status
Nicholas Skaggs (community) Approve
Review via email: mp+260659@code.launchpad.net

Description of the change

Fixes the last issue of bug 1126449 - the date range query generated now also includes the end date properly.

To post a comment you must log in.
Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

Nice! The php syntax for adding a day is different. P1D struck me as weird at first.

review: Approve
Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

I will ask though, why do we need to go beyond the end date? Is the sql query the issue?

Revision history for this message
Daniel Kessel (dkessel) wrote :

Yes, the SQL query was the issue. The old statement was something like (example with today) "... AND date <= '2015/06/01'", which does not match datetime values like "2015/06/01 00:11:22". The new statement is something like "... AND date < '2015/06/02'", which will include all of today's results, but none of tomorrow's.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'modules/qatracker/report/qatracker.report.testers.php'
2--- modules/qatracker/report/qatracker.report.testers.php 2012-11-19 20:35:32 +0000
3+++ modules/qatracker/report/qatracker.report.testers.php 2015-05-31 14:59:28 +0000
4@@ -54,7 +54,8 @@
5 $query->condition('qatracker_result.date', DateTime::createFromFormat('m/d/Y', $_POST['date_from'])->format("Ymd"), ">=");
6 }
7 if(array_key_exists("date_to", $_POST) && $_POST['date_to']) {
8- $query->condition('qatracker_result.date', DateTime::createFromFormat('m/d/Y', $_POST['date_to'])->format("Ymd"), "<=");
9+ $day_after_date_to = DateTime::createFromFormat('m/d/Y', $_POST['date_to'])->add(new DateInterval("P1D"));
10+ $query->condition('qatracker_result.date', $day_after_date_to->format("Ymd"), "<");
11 }
12 $query->orderBy('count', 'DESC');
13 $query->condition('qatracker_milestone.siteid', $site->id);

Subscribers

People subscribed via source and target branches