1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-19 05:12:41 +01:00

Query for recurring event parents should accept a "not a child of anything" clause

Summary: Closes T8371, Query for recurring event parents should accept a "not a child of anything" clause

Test Plan: querying for a list of events with recurring events should still work the same.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T8371

Differential Revision: https://secure.phabricator.com/D13140
This commit is contained in:
lkassianik 2015-06-03 09:27:39 -07:00
parent c26ea062d1
commit d3a84687ba

View file

@ -10,6 +10,7 @@ final class PhabricatorCalendarEventQuery
private $inviteePHIDs;
private $creatorPHIDs;
private $isCancelled;
private $eventsWithNoParent;
private $instanceSequencePairs;
private $generateGhosts = false;
@ -50,6 +51,11 @@ final class PhabricatorCalendarEventQuery
return $this;
}
public function withEventsWithNoParent($events_with_no_parent) {
$this->eventsWithNoParent = $events_with_no_parent;
return $this;
}
public function withInstanceSequencePairs(array $pairs) {
$this->instanceSequencePairs = $pairs;
return $this;
@ -272,6 +278,12 @@ final class PhabricatorCalendarEventQuery
(int)$this->isCancelled);
}
if ($this->eventsWithNoParent == true) {
$where[] = qsprintf(
$conn_r,
'event.instanceOfEventPHID IS NULL');
}
if ($this->instanceSequencePairs !== null) {
$sql = array();
@ -339,9 +351,7 @@ final class PhabricatorCalendarEventQuery
$instance_of = $event->getInstanceOfEventPHID();
if ($instance_of) {
if ($instance_of != $event->getPHID() || $event->getIsGhostEvent()) {
$instance_of_event_phids[] = $event->getInstanceOfEventPHID();
}
$instance_of_event_phids[] = $instance_of;
}
}
@ -349,6 +359,7 @@ final class PhabricatorCalendarEventQuery
$recurring_events = id(new PhabricatorCalendarEventQuery())
->setViewer($viewer)
->withPHIDs($instance_of_event_phids)
->withEventsWithNoParent(true)
->execute();
$recurring_events = mpull($recurring_events, null, 'getPHID');