2014-01-15 10:02:24 -08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class HeraldTranscriptGarbageCollector
|
|
|
|
extends PhabricatorGarbageCollector {
|
|
|
|
|
2015-10-01 16:58:43 -07:00
|
|
|
const COLLECTORCONST = 'herald.transcripts';
|
|
|
|
|
|
|
|
public function getCollectorName() {
|
|
|
|
return pht('Herald Transcripts');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getDefaultRetentionPolicy() {
|
|
|
|
return phutil_units('30 days in seconds');
|
|
|
|
}
|
|
|
|
|
2015-10-02 09:17:24 -07:00
|
|
|
protected function collectGarbage() {
|
2014-01-15 10:02:24 -08:00
|
|
|
$table = new HeraldTranscript();
|
|
|
|
$conn_w = $table->establishConnection('w');
|
|
|
|
|
|
|
|
queryfx(
|
|
|
|
$conn_w,
|
|
|
|
'UPDATE %T SET
|
|
|
|
objectTranscript = "",
|
|
|
|
ruleTranscripts = "",
|
|
|
|
conditionTranscripts = "",
|
|
|
|
applyTranscripts = "",
|
|
|
|
garbageCollected = 1
|
2015-06-15 07:38:28 +10:00
|
|
|
WHERE garbageCollected = 0 AND time < %d
|
2014-01-15 10:02:24 -08:00
|
|
|
LIMIT 100',
|
|
|
|
$table->getTableName(),
|
2015-10-02 09:17:24 -07:00
|
|
|
$this->getGarbageEpoch());
|
2014-01-15 10:02:24 -08:00
|
|
|
|
|
|
|
return ($conn_w->getAffectedRows() == 100);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|