2014-01-15 19:02:31 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class ConduitLogGarbageCollector
|
|
|
|
extends PhabricatorGarbageCollector {
|
|
|
|
|
2015-10-02 01:58:43 +02:00
|
|
|
const COLLECTORCONST = 'conduit.logs';
|
|
|
|
|
|
|
|
public function getCollectorName() {
|
|
|
|
return pht('Conduit Logs');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getDefaultRetentionPolicy() {
|
|
|
|
return phutil_units('180 days in seconds');
|
|
|
|
}
|
|
|
|
|
2015-10-02 18:17:24 +02:00
|
|
|
protected function collectGarbage() {
|
2014-01-15 19:02:31 +01:00
|
|
|
$table = new PhabricatorConduitMethodCallLog();
|
|
|
|
$conn_w = $table->establishConnection('w');
|
2015-10-02 18:17:24 +02:00
|
|
|
|
2014-01-15 19:02:31 +01:00
|
|
|
queryfx(
|
|
|
|
$conn_w,
|
|
|
|
'DELETE FROM %T WHERE dateCreated < %d
|
|
|
|
ORDER BY dateCreated ASC LIMIT 100',
|
|
|
|
$table->getTableName(),
|
2015-10-02 18:17:24 +02:00
|
|
|
$this->getGarbageEpoch());
|
2014-01-15 19:02:31 +01:00
|
|
|
|
|
|
|
return ($conn_w->getAffectedRows() == 100);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|