mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-18 09:48:39 +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())
|
$revisions = id(new DifferentialRevisionQuery())
|
||||||
->setViewer($viewer)
|
->setViewer($viewer)
|
||||||
->withAuthors(array($viewer->getPHID()))
|
->withAuthors(array($viewer->getPHID()))
|
||||||
->withStatus(DifferentialLegacyQuery::STATUS_OPEN)
|
->withIsOpen(true)
|
||||||
->requireCapabilities(
|
->requireCapabilities(
|
||||||
array(
|
array(
|
||||||
PhabricatorPolicyCapability::CAN_VIEW,
|
PhabricatorPolicyCapability::CAN_VIEW,
|
||||||
|
|
|
@ -808,7 +808,7 @@ final class DifferentialRevisionViewController extends DifferentialController {
|
||||||
|
|
||||||
$query = id(new DifferentialRevisionQuery())
|
$query = id(new DifferentialRevisionQuery())
|
||||||
->setViewer($this->getRequest()->getUser())
|
->setViewer($this->getRequest()->getUser())
|
||||||
->withStatus(DifferentialLegacyQuery::STATUS_OPEN)
|
->withIsOpen(true)
|
||||||
->withUpdatedEpochBetween($recent, null)
|
->withUpdatedEpochBetween($recent, null)
|
||||||
->setOrder(DifferentialRevisionQuery::ORDER_MODIFIED)
|
->setOrder(DifferentialRevisionQuery::ORDER_MODIFIED)
|
||||||
->setLimit(10)
|
->setLimit(10)
|
||||||
|
|
|
@ -26,6 +26,7 @@ final class DifferentialRevisionQuery
|
||||||
private $updatedEpochMin;
|
private $updatedEpochMin;
|
||||||
private $updatedEpochMax;
|
private $updatedEpochMax;
|
||||||
private $statuses;
|
private $statuses;
|
||||||
|
private $isOpen;
|
||||||
|
|
||||||
const ORDER_MODIFIED = 'order-modified';
|
const ORDER_MODIFIED = 'order-modified';
|
||||||
const ORDER_CREATED = 'order-created';
|
const ORDER_CREATED = 'order-created';
|
||||||
|
@ -152,6 +153,11 @@ final class DifferentialRevisionQuery
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function withIsOpen($is_open) {
|
||||||
|
$this->isOpen = $is_open;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter results to revisions on given branches.
|
* Filter results to revisions on given branches.
|
||||||
|
@ -718,6 +724,20 @@ final class DifferentialRevisionQuery
|
||||||
DifferentialLegacyQuery::getLegacyValues($this->statuses));
|
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);
|
$where[] = $this->buildWhereClauseParts($conn_r);
|
||||||
return $this->formatWhereClause($where);
|
return $this->formatWhereClause($where);
|
||||||
}
|
}
|
||||||
|
|
|
@ -268,7 +268,7 @@ final class DifferentialRevisionSearchEngine
|
||||||
$blocking_revisions = id(new DifferentialRevisionQuery())
|
$blocking_revisions = id(new DifferentialRevisionQuery())
|
||||||
->setViewer($viewer)
|
->setViewer($viewer)
|
||||||
->withPHIDs($revision_phids)
|
->withPHIDs($revision_phids)
|
||||||
->withStatus(DifferentialLegacyQuery::STATUS_OPEN)
|
->withIsOpen(true)
|
||||||
->execute();
|
->execute();
|
||||||
$blocking_revisions = mpull($blocking_revisions, null, 'getPHID');
|
$blocking_revisions = mpull($blocking_revisions, null, 'getPHID');
|
||||||
|
|
||||||
|
|
|
@ -1758,7 +1758,7 @@ final class DiffusionBrowseController extends DiffusionController {
|
||||||
$revisions = id(new DifferentialRevisionQuery())
|
$revisions = id(new DifferentialRevisionQuery())
|
||||||
->setViewer($viewer)
|
->setViewer($viewer)
|
||||||
->withPath($repository->getID(), $path_id)
|
->withPath($repository->getID(), $path_id)
|
||||||
->withStatus(DifferentialLegacyQuery::STATUS_OPEN)
|
->withIsOpen(true)
|
||||||
->withUpdatedEpochBetween($recent, null)
|
->withUpdatedEpochBetween($recent, null)
|
||||||
->setOrder(DifferentialRevisionQuery::ORDER_MODIFIED)
|
->setOrder(DifferentialRevisionQuery::ORDER_MODIFIED)
|
||||||
->setLimit(10)
|
->setLimit(10)
|
||||||
|
|
Loading…
Add table
Reference in a new issue