Differential D14219 Diff 34352 src/applications/daemon/garbagecollector/PhabricatorDaemonTaskGarbageCollector.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/daemon/garbagecollector/PhabricatorDaemonTaskGarbageCollector.php
| <?php | <?php | ||||
| final class PhabricatorDaemonTaskGarbageCollector | final class PhabricatorDaemonTaskGarbageCollector | ||||
| extends PhabricatorGarbageCollector { | extends PhabricatorGarbageCollector { | ||||
| const COLLECTORCONST = 'worker.tasks'; | const COLLECTORCONST = 'worker.tasks'; | ||||
| public function getCollectorName() { | public function getCollectorName() { | ||||
| return pht('Archived Tasks'); | return pht('Archived Tasks'); | ||||
| } | } | ||||
| public function getDefaultRetentionPolicy() { | public function getDefaultRetentionPolicy() { | ||||
| return phutil_units('14 days in seconds'); | return phutil_units('14 days in seconds'); | ||||
| } | } | ||||
| public function collectGarbage() { | protected function collectGarbage() { | ||||
| $key = 'gcdaemon.ttl.task-archive'; | |||||
| $ttl = PhabricatorEnv::getEnvConfig($key); | |||||
| if ($ttl <= 0) { | |||||
| return false; | |||||
| } | |||||
| $table = new PhabricatorWorkerArchiveTask(); | $table = new PhabricatorWorkerArchiveTask(); | ||||
| $data_table = new PhabricatorWorkerTaskData(); | $data_table = new PhabricatorWorkerTaskData(); | ||||
| $conn_w = $table->establishConnection('w'); | $conn_w = $table->establishConnection('w'); | ||||
| $tasks = id(new PhabricatorWorkerArchiveTaskQuery()) | $tasks = id(new PhabricatorWorkerArchiveTaskQuery()) | ||||
| ->withDateCreatedBefore(time() - $ttl) | ->withDateCreatedBefore($this->getGarbageEpoch()) | ||||
| ->setLimit(100) | |||||
| ->execute(); | ->execute(); | ||||
| if (!$tasks) { | if (!$tasks) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| $data_ids = array_filter(mpull($tasks, 'getDataID')); | $data_ids = array_filter(mpull($tasks, 'getDataID')); | ||||
| $task_ids = mpull($tasks, 'getID'); | $task_ids = mpull($tasks, 'getID'); | ||||
| $table->openTransaction(); | $table->openTransaction(); | ||||
| Show All 18 Lines | |||||