Differential D14219 Diff 34352 src/applications/herald/garbagecollector/HeraldTranscriptGarbageCollector.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/herald/garbagecollector/HeraldTranscriptGarbageCollector.php
| <?php | <?php | ||||
| final class HeraldTranscriptGarbageCollector | final class HeraldTranscriptGarbageCollector | ||||
| extends PhabricatorGarbageCollector { | extends PhabricatorGarbageCollector { | ||||
| const COLLECTORCONST = 'herald.transcripts'; | const COLLECTORCONST = 'herald.transcripts'; | ||||
| public function getCollectorName() { | public function getCollectorName() { | ||||
| return pht('Herald Transcripts'); | return pht('Herald Transcripts'); | ||||
| } | } | ||||
| public function getDefaultRetentionPolicy() { | public function getDefaultRetentionPolicy() { | ||||
| return phutil_units('30 days in seconds'); | return phutil_units('30 days in seconds'); | ||||
| } | } | ||||
| public function collectGarbage() { | protected function collectGarbage() { | ||||
| $ttl = PhabricatorEnv::getEnvConfig('gcdaemon.ttl.herald-transcripts'); | |||||
| if ($ttl <= 0) { | |||||
| return false; | |||||
| } | |||||
| $table = new HeraldTranscript(); | $table = new HeraldTranscript(); | ||||
| $conn_w = $table->establishConnection('w'); | $conn_w = $table->establishConnection('w'); | ||||
| queryfx( | queryfx( | ||||
| $conn_w, | $conn_w, | ||||
| 'UPDATE %T SET | 'UPDATE %T SET | ||||
| objectTranscript = "", | objectTranscript = "", | ||||
| ruleTranscripts = "", | ruleTranscripts = "", | ||||
| conditionTranscripts = "", | conditionTranscripts = "", | ||||
| applyTranscripts = "", | applyTranscripts = "", | ||||
| garbageCollected = 1 | garbageCollected = 1 | ||||
| WHERE garbageCollected = 0 AND time < %d | WHERE garbageCollected = 0 AND time < %d | ||||
| LIMIT 100', | LIMIT 100', | ||||
| $table->getTableName(), | $table->getTableName(), | ||||
| time() - $ttl); | $this->getGarbageEpoch()); | ||||
| return ($conn_w->getAffectedRows() == 100); | return ($conn_w->getAffectedRows() == 100); | ||||
| } | } | ||||
| } | } | ||||