1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-25 16:22:43 +01:00

Replace legacy Differential queries for "open" revisions with a modern mechanism

Summary: Ref T2543. Several queries want only open revisions. Provide a tailored, non-legacy way to issue that query.

Test Plan: Viewed some of these callsites (e.g., "Similar open revisions affecting these files"), saw only open revisions.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T2543

Differential Revision: https://secure.phabricator.com/D18395
This commit is contained in:
epriestley 2017-08-11 09:18:47 -07:00
parent 212d4d0dc7
commit 50dfdb8d03
5 changed files with 24 additions and 4 deletions

View file

@ -177,7 +177,7 @@ final class DifferentialDiffViewController extends DifferentialController {
$revisions = id(new DifferentialRevisionQuery())
->setViewer($viewer)
->withAuthors(array($viewer->getPHID()))
->withStatus(DifferentialLegacyQuery::STATUS_OPEN)
->withIsOpen(true)
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,

View file

@ -808,7 +808,7 @@ final class DifferentialRevisionViewController extends DifferentialController {
$query = id(new DifferentialRevisionQuery())
->setViewer($this->getRequest()->getUser())
->withStatus(DifferentialLegacyQuery::STATUS_OPEN)
->withIsOpen(true)
->withUpdatedEpochBetween($recent, null)
->setOrder(DifferentialRevisionQuery::ORDER_MODIFIED)
->setLimit(10)

View file

@ -26,6 +26,7 @@ final class DifferentialRevisionQuery
private $updatedEpochMin;
private $updatedEpochMax;
private $statuses;
private $isOpen;
const ORDER_MODIFIED = 'order-modified';
const ORDER_CREATED = 'order-created';
@ -152,6 +153,11 @@ final class DifferentialRevisionQuery
return $this;
}
public function withIsOpen($is_open) {
$this->isOpen = $is_open;
return $this;
}
/**
* Filter results to revisions on given branches.
@ -718,6 +724,20 @@ final class DifferentialRevisionQuery
DifferentialLegacyQuery::getLegacyValues($this->statuses));
}
if ($this->isOpen !== null) {
if ($this->isOpen) {
$statuses = DifferentialLegacyQuery::getQueryValues(
DifferentialLegacyQuery::STATUS_OPEN);
} else {
$statuses = DifferentialLegacyQuery::getQueryValues(
DifferentialLegacyQuery::STATUS_CLOSED);
}
$where[] = qsprintf(
$conn_r,
'r.status in (%Ls)',
$statuses);
}
$where[] = $this->buildWhereClauseParts($conn_r);
return $this->formatWhereClause($where);
}

View file

@ -268,7 +268,7 @@ final class DifferentialRevisionSearchEngine
$blocking_revisions = id(new DifferentialRevisionQuery())
->setViewer($viewer)
->withPHIDs($revision_phids)
->withStatus(DifferentialLegacyQuery::STATUS_OPEN)
->withIsOpen(true)
->execute();
$blocking_revisions = mpull($blocking_revisions, null, 'getPHID');

View file

@ -1758,7 +1758,7 @@ final class DiffusionBrowseController extends DiffusionController {
$revisions = id(new DifferentialRevisionQuery())
->setViewer($viewer)
->withPath($repository->getID(), $path_id)
->withStatus(DifferentialLegacyQuery::STATUS_OPEN)
->withIsOpen(true)
->withUpdatedEpochBetween($recent, null)
->setOrder(DifferentialRevisionQuery::ORDER_MODIFIED)
->setLimit(10)