From 5c4a9ac9e582594b62b3086dcefef086982337be Mon Sep 17 00:00:00 2001 From: Edward Speyer Date: Wed, 1 May 2013 10:22:28 +0100 Subject: [PATCH] Use LiskDAOSet's loadRelativeEdges with ReleephRequest Summary: `ReleephRequest`s contain the PHID for a `PhabricatorRepositoryCommit`, and commits have an edge to a `DifferentialRevision`. Commits are loaded with the `loadOneRelative()` method that loads the commits for every `ReleephRequest` in a `LiskDAOSet`, but the edges are loaded indivdually. A page with N RQs on it makes one DB query for the commits, but N queries for the `TYPE_COMMIT_HAS_DREV` edges. This diff uses `loadRelativeEdges` instead to load the edges all in one query. Test Plan: {F42290} Reviewers: wez, epriestley Reviewed By: epriestley CC: epriestley, vrana, aran Maniphest Tasks: T2714 Differential Revision: https://secure.phabricator.com/D5820 --- src/applications/releeph/storage/ReleephRequest.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/applications/releeph/storage/ReleephRequest.php b/src/applications/releeph/storage/ReleephRequest.php index 8f8df2b566..ce01ead6d8 100644 --- a/src/applications/releeph/storage/ReleephRequest.php +++ b/src/applications/releeph/storage/ReleephRequest.php @@ -228,10 +228,13 @@ final class ReleephRequest extends ReleephDAO { } public function loadRequestCommitDiffPHID() { - $revision_phid = PhabricatorEdgeQuery::loadDestinationPHIDs( - $this->getRequestCommitPHID(), - PhabricatorEdgeConfig::TYPE_COMMIT_HAS_DREV); - return reset($revision_phid); + $commit = $this->loadPhabricatorRepositoryCommit(); + if ($commit) { + $edges = $this + ->loadPhabricatorRepositoryCommit() + ->loadRelativeEdges(PhabricatorEdgeConfig::TYPE_COMMIT_HAS_DREV); + return head(array_keys($edges)); + } }