1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-30 02:32:42 +01:00

Make PhabricatorProjectQuery extend PhabricatorOffsetPagedQuery

Summary: This class predates PhabricatorQuery; reduce code duplication.

Test Plan: Loaded projects, ran conduit call with offset and limit.

Reviewers: vrana, btrahan

Reviewed By: vrana

CC: aran

Maniphest Tasks: T603

Differential Revision: https://secure.phabricator.com/D3180
This commit is contained in:
epriestley 2012-08-07 11:54:39 -07:00
parent b0fda3be25
commit 8668ecaf54

View file

@ -16,7 +16,7 @@
* limitations under the License.
*/
final class PhabricatorProjectQuery {
final class PhabricatorProjectQuery extends PhabricatorOffsetPagedQuery {
private $ids;
private $phids;
@ -29,9 +29,6 @@ final class PhabricatorProjectQuery {
const STATUS_ACTIVE = 'status-active';
const STATUS_ARCHIVED = 'status-archived';
private $limit;
private $offset;
private $needMembers;
public function withIDs(array $ids) {
@ -49,16 +46,6 @@ final class PhabricatorProjectQuery {
return $this;
}
public function setLimit($limit) {
$this->limit = $limit;
return $this;
}
public function setOffset($offset) {
$this->offset = $offset;
return $this;
}
public function withMemberPHIDs(array $member_phids) {
$this->memberPHIDs = $member_phids;
return $this;
@ -70,27 +57,11 @@ final class PhabricatorProjectQuery {
}
public function execute() {
$table = id(new PhabricatorProject());
$table = new PhabricatorProject();
$conn_r = $table->establishConnection('r');
$where = $this->buildWhereClause($conn_r);
$joins = $this->buildJoinsClause($conn_r);
$limit = '';
if ($this->limit) {
$limit = qsprintf(
$conn_r,
'LIMIT %d, %d',
$this->offset,
$this->limit);
} else if ($this->offset) {
$limit = qsprintf(
$conn_r,
'LIMIT %d, %d',
$this->offset,
PHP_INT_MAX);
}
$order = 'ORDER BY name';
$data = queryfx_all(
@ -100,7 +71,7 @@ final class PhabricatorProjectQuery {
$joins,
$where,
$order,
$limit);
$this->buildLimitClause($conn_r));
$projects = $table->loadAllFromArray($data);
@ -169,13 +140,7 @@ final class PhabricatorProjectQuery {
$this->phids);
}
if ($where) {
$where = 'WHERE ('.implode(') AND (', $where).')';
} else {
$where = '';
}
return $where;
return $this->formatWhereClause($where);
}
private function buildJoinsClause($conn_r) {