Differential D16267 Diff 39134 src/infrastructure/daemon/workers/query/PhabricatorWorkerArchiveTaskQuery.php
Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/daemon/workers/query/PhabricatorWorkerArchiveTaskQuery.php
<?php | <?php | ||||
final class PhabricatorWorkerArchiveTaskQuery | final class PhabricatorWorkerArchiveTaskQuery | ||||
extends PhabricatorQuery { | extends PhabricatorQuery { | ||||
private $ids; | private $ids; | ||||
private $dateModifiedSince; | private $dateModifiedSince; | ||||
private $dateCreatedBefore; | private $dateCreatedBefore; | ||||
private $objectPHIDs; | private $objectPHIDs; | ||||
private $classNames; | |||||
private $limit; | private $limit; | ||||
public function withIDs(array $ids) { | public function withIDs(array $ids) { | ||||
$this->ids = $ids; | $this->ids = $ids; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function withDateModifiedSince($timestamp) { | public function withDateModifiedSince($timestamp) { | ||||
$this->dateModifiedSince = $timestamp; | $this->dateModifiedSince = $timestamp; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function withDateCreatedBefore($timestamp) { | public function withDateCreatedBefore($timestamp) { | ||||
$this->dateCreatedBefore = $timestamp; | $this->dateCreatedBefore = $timestamp; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function withObjectPHIDs(array $phids) { | public function withObjectPHIDs(array $phids) { | ||||
$this->objectPHIDs = $phids; | $this->objectPHIDs = $phids; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function withClassNames(array $names) { | |||||
$this->classNames = $names; | |||||
return $this; | |||||
} | |||||
public function setLimit($limit) { | public function setLimit($limit) { | ||||
$this->limit = $limit; | $this->limit = $limit; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function execute() { | public function execute() { | ||||
$task_table = new PhabricatorWorkerArchiveTask(); | $task_table = new PhabricatorWorkerArchiveTask(); | ||||
Show All 22 Lines | protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { | ||||
if ($this->objectPHIDs !== null) { | if ($this->objectPHIDs !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn_r, | $conn_r, | ||||
'objectPHID IN (%Ls)', | 'objectPHID IN (%Ls)', | ||||
$this->objectPHIDs); | $this->objectPHIDs); | ||||
} | } | ||||
if ($this->dateModifiedSince) { | if ($this->dateModifiedSince !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn_r, | $conn_r, | ||||
'dateModified > %d', | 'dateModified > %d', | ||||
$this->dateModifiedSince); | $this->dateModifiedSince); | ||||
} | } | ||||
if ($this->dateCreatedBefore) { | if ($this->dateCreatedBefore !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn_r, | $conn_r, | ||||
'dateCreated < %d', | 'dateCreated < %d', | ||||
$this->dateCreatedBefore); | $this->dateCreatedBefore); | ||||
} | } | ||||
if ($this->classNames !== null) { | |||||
$where[] = qsprintf( | |||||
$conn_r, | |||||
'taskClass IN (%Ls)', | |||||
$this->classNames); | |||||
} | |||||
return $this->formatWhereClause($where); | return $this->formatWhereClause($where); | ||||
} | } | ||||
private function buildOrderClause(AphrontDatabaseConnection $conn_r) { | private function buildOrderClause(AphrontDatabaseConnection $conn_r) { | ||||
// NOTE: The garbage collector executes this query with a date constraint, | // NOTE: The garbage collector executes this query with a date constraint, | ||||
// and the query is inefficient if we don't use the same key for ordering. | // and the query is inefficient if we don't use the same key for ordering. | ||||
// See T9808 for discussion. | // See T9808 for discussion. | ||||
Show All 16 Lines |