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

Remove legacy withStatus() method from RevisionQuery

Summary: Ref T2543. All callsites are now in terms of `withStatuses()`.

Test Plan:
  - Called `differential.query` and `differential.find` from Conduit API.
  - Grepped through all `withStatus()` callsites.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T2543

Differential Revision: https://secure.phabricator.com/D18396
This commit is contained in:
epriestley 2017-08-11 09:28:05 -07:00
parent f25acf2dee
commit 13ddb15bbc
4 changed files with 11 additions and 34 deletions

View file

@ -52,12 +52,12 @@ final class DifferentialFindConduitAPIMethod
switch ($type) { switch ($type) {
case 'open': case 'open':
$query $query
->withStatus(DifferentialLegacyQuery::STATUS_OPEN) ->withIsOpen(true)
->withAuthors($guids); ->withAuthors($guids);
break; break;
case 'committable': case 'committable':
$query $query
->withStatus(DifferentialLegacyQuery::STATUS_ACCEPTED) ->withStatuses(DifferentialRevisionStatus::ACCEPTED)
->withAuthors($guids); ->withAuthors($guids);
break; break;
case 'revision-ids': case 'revision-ids':

View file

@ -150,7 +150,10 @@ final class DifferentialQueryConduitAPIMethod
} }
if ($status) { if ($status) {
$query->withStatus($status); $statuses = DifferentialLegacyQuery::getModernValues($status);
if ($statuses) {
$query->withStatuses($statuses);
}
} }
if ($order) { if ($order) {
$query->setOrder($order); $query->setOrder($order);

View file

@ -15,7 +15,7 @@ final class DifferentialLegacyQuery
return array_keys(self::getMap()); return array_keys(self::getMap());
} }
public static function getQueryValues($status) { public static function getModernValues($status) {
if ($status === self::STATUS_ANY) { if ($status === self::STATUS_ANY) {
return null; return null;
} }
@ -28,7 +28,7 @@ final class DifferentialLegacyQuery
$status)); $status));
} }
return self::getLegacyValues($map[$status]); return $map[$status];
} }
public static function getLegacyValues(array $modern_values) { public static function getLegacyValues(array $modern_values) {

View file

@ -10,8 +10,6 @@ final class DifferentialRevisionQuery
private $pathIDs = array(); private $pathIDs = array();
private $status = 'status-any';
private $authors = array(); private $authors = array();
private $draftAuthors = array(); private $draftAuthors = array();
private $ccs = array(); private $ccs = array();
@ -135,19 +133,6 @@ final class DifferentialRevisionQuery
return $this; return $this;
} }
/**
* Filter results to revisions with a given status. Provide a class constant,
* such as `DifferentialLegacyQuery::STATUS_OPEN`.
*
* @param const Class STATUS constant, like STATUS_OPEN.
* @return this
* @task config
*/
public function withStatus($status_constant) {
$this->status = $status_constant;
return $this;
}
public function withStatuses(array $statuses) { public function withStatuses(array $statuses) {
$this->statuses = $statuses; $this->statuses = $statuses;
return $this; return $this;
@ -706,17 +691,6 @@ final class DifferentialRevisionQuery
$this->updatedEpochMax); $this->updatedEpochMax);
} }
// NOTE: Although the status constants are integers in PHP, the column is a
// string column in MySQL, and MySQL won't use keys on string columns if
// you put integers in the query.
$statuses = DifferentialLegacyQuery::getQueryValues($this->status);
if ($statuses !== null) {
$where[] = qsprintf(
$conn_r,
'r.status IN (%Ls)',
$statuses);
}
if ($this->statuses !== null) { if ($this->statuses !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn_r,
@ -726,16 +700,16 @@ final class DifferentialRevisionQuery
if ($this->isOpen !== null) { if ($this->isOpen !== null) {
if ($this->isOpen) { if ($this->isOpen) {
$statuses = DifferentialLegacyQuery::getQueryValues( $statuses = DifferentialLegacyQuery::getModernValues(
DifferentialLegacyQuery::STATUS_OPEN); DifferentialLegacyQuery::STATUS_OPEN);
} else { } else {
$statuses = DifferentialLegacyQuery::getQueryValues( $statuses = DifferentialLegacyQuery::getModernValues(
DifferentialLegacyQuery::STATUS_CLOSED); DifferentialLegacyQuery::STATUS_CLOSED);
} }
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn_r,
'r.status in (%Ls)', 'r.status in (%Ls)',
$statuses); DifferentialLegacyQuery::getLegacyValues($statuses));
} }
$where[] = $this->buildWhereClauseParts($conn_r); $where[] = $this->buildWhereClauseParts($conn_r);