1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-22 05:20:56 +01:00

Attempt to optimize ghost generating code.

Summary: Ref T8394, Attempt to optimize ghost generating code.

Test Plan: Open Upcoming, cancelled only, list view query. Should not hang.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T8394

Differential Revision: https://secure.phabricator.com/D13141
This commit is contained in:
lkassianik 2015-06-03 13:01:26 -07:00
parent dfac9d7f52
commit 55c73b20ca

View file

@ -110,8 +110,7 @@ final class PhabricatorCalendarEventQuery
return $events; return $events;
} }
$map = array(); $enforced_end = null;
$instance_sequence_pairs = array();
foreach ($events as $key => $event) { foreach ($events as $key => $event) {
$sequence_start = 0; $sequence_start = 0;
@ -159,6 +158,12 @@ final class PhabricatorCalendarEventQuery
$end = $event->getRecurrenceEndDate(); $end = $event->getRecurrenceEndDate();
} else if ($this->rangeEnd) { } else if ($this->rangeEnd) {
$end = $this->rangeEnd; $end = $this->rangeEnd;
} else if ($enforced_end) {
if ($end) {
$end = min($end, $enforced_end);
} else {
$end = $enforced_end;
}
} }
if ($end) { if ($end) {
@ -167,6 +172,9 @@ final class PhabricatorCalendarEventQuery
$sequence_end++; $sequence_end++;
$datetime->modify($modify_key); $datetime->modify($modify_key);
$date = $datetime->format('U'); $date = $datetime->format('U');
if ($sequence_end > $this->getRawResultLimit() + $sequence_start) {
break;
}
} }
} else { } else {
$sequence_end = $this->getRawResultLimit() + $sequence_start; $sequence_end = $this->getRawResultLimit() + $sequence_start;
@ -175,12 +183,25 @@ final class PhabricatorCalendarEventQuery
$sequence_start = max(1, $sequence_start); $sequence_start = max(1, $sequence_start);
for ($index = $sequence_start; $index < $sequence_end; $index++) { for ($index = $sequence_start; $index < $sequence_end; $index++) {
$instance_sequence_pairs[] = array($event->getPHID(), $index);
$events[] = $event->generateNthGhost($index, $viewer); $events[] = $event->generateNthGhost($index, $viewer);
$last_key = last_key($events);
$map[$event->getPHID()][$index] = $last_key;
} }
if (count($events) >= $this->getRawResultLimit()) {
$events = msort($events, 'getDateFrom');
$events = array_slice($events, 0, $this->getRawResultLimit(), true);
$enforced_end = last($events)->getDateFrom();
}
}
}
$map = array();
$instance_sequence_pairs = array();
foreach ($events as $key => $event) {
if ($event->getIsGhostEvent()) {
$index = $event->getSequenceIndex();
$instance_sequence_pairs[] = array($event->getPHID(), $index);
$map[$event->getPHID()][$index] = $key;
} }
} }