mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-25 08:12:40 +01:00
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
This commit is contained in:
parent
925c9a71e7
commit
6d33ba7dc4
2 changed files with 2 additions and 53 deletions
|
@ -8,8 +8,6 @@
|
||||||
final class DifferentialRevisionQuery
|
final class DifferentialRevisionQuery
|
||||||
extends PhabricatorCursorPagedPolicyAwareQuery {
|
extends PhabricatorCursorPagedPolicyAwareQuery {
|
||||||
|
|
||||||
private $pathIDs = array();
|
|
||||||
|
|
||||||
private $authors = array();
|
private $authors = array();
|
||||||
private $draftAuthors = array();
|
private $draftAuthors = array();
|
||||||
private $ccs = array();
|
private $ccs = array();
|
||||||
|
@ -44,25 +42,6 @@ final class DifferentialRevisionQuery
|
||||||
|
|
||||||
/* -( Query Configuration )------------------------------------------------ */
|
/* -( 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.
|
* Find revisions affecting one or more items in a list of paths.
|
||||||
*
|
*
|
||||||
|
@ -581,13 +560,6 @@ final class DifferentialRevisionQuery
|
||||||
*/
|
*/
|
||||||
private function buildJoinsClause(AphrontDatabaseConnection $conn) {
|
private function buildJoinsClause(AphrontDatabaseConnection $conn) {
|
||||||
$joins = array();
|
$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) {
|
if ($this->paths) {
|
||||||
$path_table = new DifferentialAffectedPath();
|
$path_table = new DifferentialAffectedPath();
|
||||||
|
@ -659,20 +631,6 @@ final class DifferentialRevisionQuery
|
||||||
$viewer = $this->getViewer();
|
$viewer = $this->getViewer();
|
||||||
$where = array();
|
$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) {
|
if ($this->paths !== null) {
|
||||||
$paths = $this->paths;
|
$paths = $this->paths;
|
||||||
|
|
||||||
|
@ -839,10 +797,6 @@ final class DifferentialRevisionQuery
|
||||||
*/
|
*/
|
||||||
protected function shouldGroupQueryResultRows() {
|
protected function shouldGroupQueryResultRows() {
|
||||||
|
|
||||||
if (count($this->pathIDs) > 1) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->paths) {
|
if ($this->paths) {
|
||||||
// (If we have exactly one repository and exactly one path, we don't
|
// (If we have exactly one repository and exactly one path, we don't
|
||||||
// technically need to group, but it's simpler to always group.)
|
// technically need to group, but it's simpler to always group.)
|
||||||
|
|
|
@ -938,17 +938,12 @@ final class DiffusionBrowseController extends DiffusionController {
|
||||||
$repository = $drequest->getRepository();
|
$repository = $drequest->getRepository();
|
||||||
$path = $drequest->getPath();
|
$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'));
|
$recent = (PhabricatorTime::getNow() - phutil_units('30 days in seconds'));
|
||||||
|
|
||||||
$revisions = id(new DifferentialRevisionQuery())
|
$revisions = id(new DifferentialRevisionQuery())
|
||||||
->setViewer($viewer)
|
->setViewer($viewer)
|
||||||
->withPath($repository->getID(), $path_id)
|
->withPaths(array($path))
|
||||||
|
->withRepositoryPHIDs(array($repository->getPHID()))
|
||||||
->withIsOpen(true)
|
->withIsOpen(true)
|
||||||
->withUpdatedEpochBetween($recent, null)
|
->withUpdatedEpochBetween($recent, null)
|
||||||
->setOrder(DifferentialRevisionQuery::ORDER_MODIFIED)
|
->setOrder(DifferentialRevisionQuery::ORDER_MODIFIED)
|
||||||
|
|
Loading…
Reference in a new issue