From 6d33ba7dc40152352585fb7d2c99761efa5d1724 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 15 Mar 2021 15:56:05 -0700 Subject: [PATCH] Move Diffusion to "withPaths()" for "Recent Open Revisions", and remove "withPath()" from DifferentialRevisionQuery Summary: Ref T13639. Move Diffusion to use the new API and get rid of the old API now that it no longer has any callers. Test Plan: Grepped for remaining callers. {F8539335} Maniphest Tasks: T13639 Differential Revision: https://secure.phabricator.com/D21620 --- .../query/DifferentialRevisionQuery.php | 46 ------------------- .../controller/DiffusionBrowseController.php | 9 +--- 2 files changed, 2 insertions(+), 53 deletions(-) diff --git a/src/applications/differential/query/DifferentialRevisionQuery.php b/src/applications/differential/query/DifferentialRevisionQuery.php index c77e99d8c2..75d3e052e4 100644 --- a/src/applications/differential/query/DifferentialRevisionQuery.php +++ b/src/applications/differential/query/DifferentialRevisionQuery.php @@ -8,8 +8,6 @@ final class DifferentialRevisionQuery extends PhabricatorCursorPagedPolicyAwareQuery { - private $pathIDs = array(); - private $authors = array(); private $draftAuthors = array(); private $ccs = array(); @@ -44,25 +42,6 @@ final class DifferentialRevisionQuery /* -( Query Configuration )------------------------------------------------ */ - - /** - * Filter results to revisions which affect a Diffusion path ID in a given - * repository. You can call this multiple times to select revisions for - * several paths. - * - * @param int Diffusion repository ID. - * @param int Diffusion path ID. - * @return this - * @task config - */ - public function withPath($repository_id, $path_id) { - $this->pathIDs[] = array( - 'repositoryID' => $repository_id, - 'pathID' => $path_id, - ); - return $this; - } - /** * Find revisions affecting one or more items in a list of paths. * @@ -581,13 +560,6 @@ final class DifferentialRevisionQuery */ private function buildJoinsClause(AphrontDatabaseConnection $conn) { $joins = array(); - if ($this->pathIDs) { - $path_table = new DifferentialAffectedPath(); - $joins[] = qsprintf( - $conn, - 'JOIN %T p ON p.revisionID = r.id', - $path_table->getTableName()); - } if ($this->paths) { $path_table = new DifferentialAffectedPath(); @@ -659,20 +631,6 @@ final class DifferentialRevisionQuery $viewer = $this->getViewer(); $where = array(); - if ($this->pathIDs) { - $path_clauses = array(); - $repo_info = igroup($this->pathIDs, 'repositoryID'); - foreach ($repo_info as $repository_id => $paths) { - $path_clauses[] = qsprintf( - $conn, - '(p.repositoryID = %d AND p.pathID IN (%Ld))', - $repository_id, - ipull($paths, 'pathID')); - } - $path_clauses = qsprintf($conn, '%LO', $path_clauses); - $where[] = $path_clauses; - } - if ($this->paths !== null) { $paths = $this->paths; @@ -839,10 +797,6 @@ final class DifferentialRevisionQuery */ protected function shouldGroupQueryResultRows() { - if (count($this->pathIDs) > 1) { - return true; - } - if ($this->paths) { // (If we have exactly one repository and exactly one path, we don't // technically need to group, but it's simpler to always group.) diff --git a/src/applications/diffusion/controller/DiffusionBrowseController.php b/src/applications/diffusion/controller/DiffusionBrowseController.php index 042c21d232..549c0d649f 100644 --- a/src/applications/diffusion/controller/DiffusionBrowseController.php +++ b/src/applications/diffusion/controller/DiffusionBrowseController.php @@ -938,17 +938,12 @@ final class DiffusionBrowseController extends DiffusionController { $repository = $drequest->getRepository(); $path = $drequest->getPath(); - $path_map = id(new DiffusionPathIDQuery(array($path)))->loadPathIDs(); - $path_id = idx($path_map, $path); - if (!$path_id) { - return null; - } - $recent = (PhabricatorTime::getNow() - phutil_units('30 days in seconds')); $revisions = id(new DifferentialRevisionQuery()) ->setViewer($viewer) - ->withPath($repository->getID(), $path_id) + ->withPaths(array($path)) + ->withRepositoryPHIDs(array($repository->getPHID())) ->withIsOpen(true) ->withUpdatedEpochBetween($recent, null) ->setOrder(DifferentialRevisionQuery::ORDER_MODIFIED)