Skip to content
Extraits de code Groupes Projets
Valider 04de8d46 rédigé par diosmosis's avatar diosmosis
Parcourir les fichiers

When segment creation time (or just earliest archive date) is greater than end...

When segment creation time (or just earliest archive date) is greater than end date of requested range to archive, use end date as override for start of archiving request range.
parent 5447bd01
Branches
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -65,7 +65,16 @@ class SegmentArchivingRequestUrlProvider ...@@ -65,7 +65,16 @@ class SegmentArchivingRequestUrlProvider
// use the minimum allowed date as the start date // use the minimum allowed date as the start date
$periodObj = PeriodFactory::build($period, $date); $periodObj = PeriodFactory::build($period, $date);
if ($periodObj->getDateStart()->getTimestamp() < $oldestDateToProcessForNewSegment->getTimestamp()) { if ($periodObj->getDateStart()->getTimestamp() < $oldestDateToProcessForNewSegment->getTimestamp()) {
$date = $oldestDateToProcessForNewSegment->toString().','.$periodObj->getDateEnd(); $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
// start date equal to the end date, so less archiving occurs, and no fatal error occurs.
if ($oldestDateToProcessForNewSegment->getTimestamp() > $endDate->getTimestamp()) {
$oldestDateToProcessForNewSegment = $endDate;
}
$date = $oldestDateToProcessForNewSegment->toString().','.$endDate;
} }
return $date; return $date;
......
...@@ -59,6 +59,12 @@ class SegmentArchivingRequestUrlProviderTest extends \PHPUnit_Framework_TestCase ...@@ -59,6 +59,12 @@ class SegmentArchivingRequestUrlProviderTest extends \PHPUnit_Framework_TestCase
'ts_created' => '2011-01-01', 'ts_created' => '2011-01-01',
'definition' => 'countryCode==ca', 'definition' => 'countryCode==ca',
'enable_only_idsite' => 0 'enable_only_idsite' => 0
),
array(
'ts_created' => '2015-03-01',
'definition' => 'pageUrl==a',
'enable_only_idsite' => 1
) )
); );
} }
...@@ -159,6 +165,15 @@ class SegmentArchivingRequestUrlProviderTest extends \PHPUnit_Framework_TestCase ...@@ -159,6 +165,15 @@ class SegmentArchivingRequestUrlProviderTest extends \PHPUnit_Framework_TestCase
'countryCode==us', 'countryCode==us',
"2015-02-19,2015-03-01" "2015-02-19,2015-03-01"
), ),
array( // test when creation_time is greater than date range end date
'creation_time',
1,
'2010-02-01,2015-02-22',
'week',
'pageUrl==a',
'2015-02-22,2015-02-22'
),
); );
} }
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter