mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-21 04:50:55 +01:00
Add sanity to DifferentialRevisionQuery
Summary: Changed cc/reviewer search to be a union/or instead of intersection/and within each list. Also added support to search for multiple authors (same behavior as cc/reviewer), and updated conduit call to match. (See discussion on D1158.) Test Plan: Used the conduit call to search for revisions with one of 2 people on the cc list, and checked the results to see that it wasn't constraining to requiring both be on the cc list. Reviewers: epriestley, jungejason, btrahan Reviewed By: epriestley CC: aran, nh, epriestley Differential Revision: 1179
This commit is contained in:
parent
55ff8c5829
commit
74f710a437
2 changed files with 46 additions and 39 deletions
|
@ -39,7 +39,7 @@ class ConduitAPI_differential_query_Method extends ConduitAPIMethod {
|
||||||
$order_types = implode(', ', $order_types);
|
$order_types = implode(', ', $order_types);
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'author' => 'optional phid',
|
'authors' => 'optional list<phid>',
|
||||||
'ccs' => 'optional list<phid>',
|
'ccs' => 'optional list<phid>',
|
||||||
'reviewers' => 'optional list<phid>',
|
'reviewers' => 'optional list<phid>',
|
||||||
'paths' => 'optional list<string>',
|
'paths' => 'optional list<string>',
|
||||||
|
@ -62,7 +62,7 @@ class ConduitAPI_differential_query_Method extends ConduitAPIMethod {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function execute(ConduitAPIRequest $request) {
|
protected function execute(ConduitAPIRequest $request) {
|
||||||
$author = $request->getValue('author');
|
$authors = $request->getValue('authors');
|
||||||
$ccs = $request->getValue('ccs');
|
$ccs = $request->getValue('ccs');
|
||||||
$reviewers = $request->getValue('reviewers');
|
$reviewers = $request->getValue('reviewers');
|
||||||
$paths = $request->getValue('paths');
|
$paths = $request->getValue('paths');
|
||||||
|
@ -74,7 +74,7 @@ class ConduitAPI_differential_query_Method extends ConduitAPIMethod {
|
||||||
$phids = $request->getValue('phids');
|
$phids = $request->getValue('phids');
|
||||||
|
|
||||||
$query = new DifferentialRevisionQuery();
|
$query = new DifferentialRevisionQuery();
|
||||||
$query->withAuthor($author);
|
$query->withAuthors($authors);
|
||||||
if ($ccs) {
|
if ($ccs) {
|
||||||
$query->withCCs($ccs);
|
$query->withCCs($ccs);
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ final class DifferentialRevisionQuery {
|
||||||
const STATUS_ANY = 'status-any';
|
const STATUS_ANY = 'status-any';
|
||||||
const STATUS_OPEN = 'status-open';
|
const STATUS_OPEN = 'status-open';
|
||||||
|
|
||||||
private $author = null;
|
private $authors = array();
|
||||||
private $ccs = array();
|
private $ccs = array();
|
||||||
private $reviewers = array();
|
private $reviewers = array();
|
||||||
private $revIDs = array();
|
private $revIDs = array();
|
||||||
|
@ -84,20 +84,31 @@ final class DifferentialRevisionQuery {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter results to revisions authored by a given PHID. If an invalid PHID is
|
* Filter results to revisions authored by a given PHID.
|
||||||
* provided, no results will be returned.
|
|
||||||
*
|
*
|
||||||
* @param phid Author PHID
|
* @param phid Author PHID
|
||||||
* @return this
|
* @return this
|
||||||
* @task config
|
* @task config
|
||||||
*/
|
*/
|
||||||
public function withAuthor($author_phid) {
|
public function withAuthor($author_phid) {
|
||||||
$this->author = $author_phid;
|
$this->authors[] = $author_phid;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter results to revisions which CC all of the listed people. Calling this
|
* Filter results to revisions authored by one of the given PHIDs.
|
||||||
|
*
|
||||||
|
* @param array List of PHIDs of authors
|
||||||
|
* @return this
|
||||||
|
* @task config
|
||||||
|
*/
|
||||||
|
public function withAuthors(array $author_list) {
|
||||||
|
$this->authors = $author_list;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter results to revisions which CC one of the listed people. Calling this
|
||||||
* function will clear anything set by previous calls to withCCs or withCC.
|
* function will clear anything set by previous calls to withCCs or withCC.
|
||||||
*
|
*
|
||||||
* @param array List of PHIDs of subscribers
|
* @param array List of PHIDs of subscribers
|
||||||
|
@ -110,9 +121,7 @@ final class DifferentialRevisionQuery {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a PHID to the list of CCs that must be present on the revision. Calling
|
* Filter results to include revisions which CC the given PHID.
|
||||||
* this multiple times will continue to add CC PHID constraints, and will not
|
|
||||||
* clear anything set by previous calls to withCCs or withCC.
|
|
||||||
*
|
*
|
||||||
* @param phid CC PHID
|
* @param phid CC PHID
|
||||||
* @return this
|
* @return this
|
||||||
|
@ -124,7 +133,7 @@ final class DifferentialRevisionQuery {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter results to revisions that have all of the provided PHIDs as
|
* Filter results to revisions that have one of the provided PHIDs as
|
||||||
* reviewers. Calling this function will clear anything set by previous calls
|
* reviewers. Calling this function will clear anything set by previous calls
|
||||||
* to withReviewers or withReviewer.
|
* to withReviewers or withReviewer.
|
||||||
*
|
*
|
||||||
|
@ -138,10 +147,8 @@ final class DifferentialRevisionQuery {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a PHID to the list of reviewers that must be present on the revision.
|
* Filter results to include revisions which have the given PHID as a
|
||||||
* Calling this multiple times will continue to add reviewer PHID constraints,
|
* reviewer.
|
||||||
* and will not clear anything set by previous calls to withReviewers or
|
|
||||||
* withReviewer.
|
|
||||||
*
|
*
|
||||||
* @param phid reviewer PHID
|
* @param phid reviewer PHID
|
||||||
* @return this
|
* @return this
|
||||||
|
@ -321,6 +328,26 @@ final class DifferentialRevisionQuery {
|
||||||
$path_table->getTableName());
|
$path_table->getTableName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->ccs) {
|
||||||
|
$joins[] = qsprintf(
|
||||||
|
$conn_r,
|
||||||
|
'JOIN %T rel ON rel.revisionID = r.id '.
|
||||||
|
'AND rel.relation = %s AND rel.objectPHID in (%Ls)',
|
||||||
|
DifferentialRevision::RELATIONSHIP_TABLE,
|
||||||
|
DifferentialRevision::RELATION_SUBSCRIBED,
|
||||||
|
$this->ccs);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->reviewers) {
|
||||||
|
$joins[] = qsprintf(
|
||||||
|
$conn_r,
|
||||||
|
'JOIN %T rel ON rel.revisionID = r.id '.
|
||||||
|
'AND rel.relation = %s AND rel.objectPHID in (%Ls)',
|
||||||
|
DifferentialRevision::RELATIONSHIP_TABLE,
|
||||||
|
DifferentialRevision::RELATION_REVIEWER,
|
||||||
|
$this->reviewers);
|
||||||
|
}
|
||||||
|
|
||||||
$joins = implode(' ', $joins);
|
$joins = implode(' ', $joins);
|
||||||
|
|
||||||
return $joins;
|
return $joins;
|
||||||
|
@ -347,31 +374,11 @@ final class DifferentialRevisionQuery {
|
||||||
$where[] = $path_clauses;
|
$where[] = $path_clauses;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->author) {
|
if ($this->authors) {
|
||||||
$where[] = qsprintf(
|
$where[] = qsprintf(
|
||||||
$conn_r,
|
$conn_r,
|
||||||
'authorPHID = %s',
|
'authorPHID IN (%Ls)',
|
||||||
$this->author);
|
$this->authors);
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($this->ccs as $cc) {
|
|
||||||
$where[] = qsprintf(
|
|
||||||
$conn_r,
|
|
||||||
'id IN '.
|
|
||||||
'(SELECT revisionID FROM %T WHERE relation = %s AND objectPHID = %s)',
|
|
||||||
DifferentialRevision::RELATIONSHIP_TABLE,
|
|
||||||
DifferentialRevision::RELATION_SUBSCRIBED,
|
|
||||||
$cc);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($this->reviewers as $reviewer) {
|
|
||||||
$where[] = qsprintf(
|
|
||||||
$conn_r,
|
|
||||||
'id IN '.
|
|
||||||
'(SELECT revisionID FROM %T WHERE relation = %s AND objectPHID = %s)',
|
|
||||||
DifferentialRevision::RELATIONSHIP_TABLE,
|
|
||||||
DifferentialRevision::RELATION_REVIEWER,
|
|
||||||
$reviewer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->revIDs) {
|
if ($this->revIDs) {
|
||||||
|
|
Loading…
Reference in a new issue