mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-26 07:20:57 +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:
parent
212d4d0dc7
commit
50dfdb8d03
5 changed files with 24 additions and 4 deletions
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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');
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue