diff options
author | mattab <matthieu.aubry@gmail.com> | 2015-03-19 10:30:03 +0300 |
---|---|---|
committer | mattab <matthieu.aubry@gmail.com> | 2015-03-19 10:30:03 +0300 |
commit | 0dcd19441ffcc977c275f5d7823acf493f98a677 (patch) | |
tree | fa844128dad9e2ed35c604881a5718c28cdc8997 | |
parent | dfb9860120cf78e75444128296b175b5124030ad (diff) |
Make sure to pre-process in the past
-rw-r--r-- | core/CronArchive/SegmentArchivingRequestUrlProvider.php | 7 | ||||
-rw-r--r-- | tests/PHPUnit/Unit/CronArchive/SegmentArchivingRequestUrlProviderTest.php | 9 |
2 files changed, 12 insertions, 4 deletions
diff --git a/core/CronArchive/SegmentArchivingRequestUrlProvider.php b/core/CronArchive/SegmentArchivingRequestUrlProvider.php index ddbaef0198..9dafd9f66e 100644 --- a/core/CronArchive/SegmentArchivingRequestUrlProvider.php +++ b/core/CronArchive/SegmentArchivingRequestUrlProvider.php @@ -64,8 +64,8 @@ class SegmentArchivingRequestUrlProvider // if the start date for the archiving request is before the minimum date allowed for processing this segment, // use the minimum allowed date as the start date $periodObj = PeriodFactory::build($period, $date); + $endDate = $periodObj->getDateEnd(); if ($periodObj->getDateStart()->getTimestamp() < $oldestDateToProcessForNewSegment->getTimestamp()) { - $endDate = $periodObj->getDateEnd(); // if the creation time of a segment is older than the end date of the archiving request range, we cannot // blindly rewrite the date string, since the resulting range would be incorrect. instead we make the @@ -74,8 +74,8 @@ class SegmentArchivingRequestUrlProvider $oldestDateToProcessForNewSegment = $endDate; } - $date = $oldestDateToProcessForNewSegment->toString().','.$endDate; } + $date = $oldestDateToProcessForNewSegment->toString().','.$endDate; return $date; } @@ -84,11 +84,10 @@ class SegmentArchivingRequestUrlProvider { if ($this->processNewSegmentsFrom == self::CREATION_TIME) { return $segmentCreatedTime; - } else if (preg_match("/^last([0-9]+)$/", $this->processNewSegmentsFrom, $matches)) { + } else if (preg_match("/^last([0-9]*)$/", $this->processNewSegmentsFrom, $matches)) { $lastN = $matches[1]; list($lastDate, $lastPeriod) = Range::getDateXPeriodsAgo($lastN, $segmentCreatedTime, 'day'); - return Date::factory($lastDate); } else { return null; diff --git a/tests/PHPUnit/Unit/CronArchive/SegmentArchivingRequestUrlProviderTest.php b/tests/PHPUnit/Unit/CronArchive/SegmentArchivingRequestUrlProviderTest.php index e405d08161..2e0fe987df 100644 --- a/tests/PHPUnit/Unit/CronArchive/SegmentArchivingRequestUrlProviderTest.php +++ b/tests/PHPUnit/Unit/CronArchive/SegmentArchivingRequestUrlProviderTest.php @@ -157,6 +157,15 @@ class SegmentArchivingRequestUrlProviderTest extends \PHPUnit_Framework_TestCase "2011-12-22,2015-03-01" ), + array( // test lastN rewinds created date by N = 1000 days + 'last3000', + 1, + $dateRange, + 'week', + 'countryCode==us', + "2003-10-15,2015-03-01" + ), + array( // test lastN rewinds now by N days (testing w/ no found segment) 'last10', 3, |