recurr
recurr copied to clipboard
Slow transform when FREQ=DAILY
I have an array of 10 or so RRULE's from which I want to calculate which of those are 'today'.
The list contains random RRULE's, one of them is like this: (Every day, 16:00 - 19:00)
DTSTART=20150428T160000;DTEND=20150428T190000;FREQ=DAILY;INTERVAL=1
So:
$transformer = new \Recurr\Transformer\ArrayTransformer();
foreach($rrules as $rrule){
$rrule = new \Recurr\Rule($rrule);
$constraint = new \Recurr\Transformer\Constraint\BetweenConstraint($start, $end, true);
$recurrences = $transformer->transform($rrule, $constraint);
// do some more stuff
}
The transform takes a lot longer than when I use this RRULE:
DTSTART=20150428T160000;DTEND=20150428T190000;FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR,SA,SU;INTERVAL=1;
But they both have the same outcome, the first RRULE shouldn't be calculated at all, it is daily so it will happen today. Or am I missing something?
Cheers
Got it a lot faster on my system at least, from 8 to 0.7 seconds w/o cache...
- Added false to transform() ($countConstraintFailures - Whether recurrences that fail the constraint's test should count towards a rule's COUNT limit.) Otherwise I was hitting the virtual limit of 732 all the time
- Changed ArrayTransformer.php line ~653
case Frequency::DAILY:
if($rule->getInterval() == 1){
$dates[] = $dtTmp;
$continue = false;
}else{
$dt->modify('+'.$rule->getInterval().' day');
}
$year = $dt->format('Y');
$month = $dt->format('n');
$day = $dt->format('j');
break;