1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +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 $inviteePHIDs;
private $creatorPHIDs; private $creatorPHIDs;
private $isCancelled; private $isCancelled;
private $eventsWithNoParent;
private $instanceSequencePairs; private $instanceSequencePairs;
private $generateGhosts = false; private $generateGhosts = false;
@ -50,6 +51,11 @@ final class PhabricatorCalendarEventQuery
return $this; return $this;
} }
public function withEventsWithNoParent($events_with_no_parent) {
$this->eventsWithNoParent = $events_with_no_parent;
return $this;
}
public function withInstanceSequencePairs(array $pairs) { public function withInstanceSequencePairs(array $pairs) {
$this->instanceSequencePairs = $pairs; $this->instanceSequencePairs = $pairs;
return $this; return $this;
@ -272,6 +278,12 @@ final class PhabricatorCalendarEventQuery
(int)$this->isCancelled); (int)$this->isCancelled);
} }
if ($this->eventsWithNoParent == true) {
$where[] = qsprintf(
$conn_r,
'event.instanceOfEventPHID IS NULL');
}
if ($this->instanceSequencePairs !== null) { if ($this->instanceSequencePairs !== null) {
$sql = array(); $sql = array();
@ -339,9 +351,7 @@ final class PhabricatorCalendarEventQuery
$instance_of = $event->getInstanceOfEventPHID(); $instance_of = $event->getInstanceOfEventPHID();
if ($instance_of) { if ($instance_of) {
if ($instance_of != $event->getPHID() || $event->getIsGhostEvent()) { $instance_of_event_phids[] = $instance_of;
$instance_of_event_phids[] = $event->getInstanceOfEventPHID();
}
} }
} }
@ -349,6 +359,7 @@ final class PhabricatorCalendarEventQuery
$recurring_events = id(new PhabricatorCalendarEventQuery()) $recurring_events = id(new PhabricatorCalendarEventQuery())
->setViewer($viewer) ->setViewer($viewer)
->withPHIDs($instance_of_event_phids) ->withPHIDs($instance_of_event_phids)
->withEventsWithNoParent(true)
->execute(); ->execute();
$recurring_events = mpull($recurring_events, null, 'getPHID'); $recurring_events = mpull($recurring_events, null, 'getPHID');