2015-10-01 17:09:27 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class DrydockLogGarbageCollector
|
|
|
|
extends PhabricatorGarbageCollector {
|
|
|
|
|
2015-10-02 01:58:43 +02:00
|
|
|
const COLLECTORCONST = 'drydock.logs';
|
|
|
|
|
|
|
|
public function getCollectorName() {
|
|
|
|
return pht('Drydock Logs');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getDefaultRetentionPolicy() {
|
|
|
|
return phutil_units('30 days in seconds');
|
|
|
|
}
|
|
|
|
|
2015-10-02 18:17:24 +02:00
|
|
|
protected function collectGarbage() {
|
2015-10-01 17:09:27 +02:00
|
|
|
$log_table = new DrydockLog();
|
|
|
|
$conn_w = $log_table->establishConnection('w');
|
|
|
|
|
|
|
|
queryfx(
|
|
|
|
$conn_w,
|
|
|
|
'DELETE FROM %T WHERE epoch <= %d LIMIT 100',
|
|
|
|
$log_table->getTableName(),
|
2015-10-02 18:17:24 +02:00
|
|
|
$this->getGarbageEpoch());
|
2015-10-01 17:09:27 +02:00
|
|
|
|
|
|
|
return ($conn_w->getAffectedRows() == 100);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|