Differential D14219 Diff 34352 src/applications/system/garbagecollector/PhabricatorSystemActionGarbageCollector.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/system/garbagecollector/PhabricatorSystemActionGarbageCollector.php
| <?php | <?php | ||||
| final class PhabricatorSystemActionGarbageCollector | final class PhabricatorSystemActionGarbageCollector | ||||
| extends PhabricatorGarbageCollector { | extends PhabricatorGarbageCollector { | ||||
| const COLLECTORCONST = 'system.actions'; | const COLLECTORCONST = 'system.actions'; | ||||
| public function getCollectorName() { | public function getCollectorName() { | ||||
| return pht('Rate Limiting Actions'); | return pht('Rate Limiting Actions'); | ||||
| } | } | ||||
| public function getDefaultRetentionPolicy() { | public function getDefaultRetentionPolicy() { | ||||
| return phutil_units('3 days in seconds'); | return phutil_units('3 days in seconds'); | ||||
| } | } | ||||
| public function collectGarbage() { | protected function collectGarbage() { | ||||
| $ttl = phutil_units('3 days in seconds'); | |||||
| $table = new PhabricatorSystemActionLog(); | $table = new PhabricatorSystemActionLog(); | ||||
| $conn_w = $table->establishConnection('w'); | $conn_w = $table->establishConnection('w'); | ||||
| queryfx( | queryfx( | ||||
| $conn_w, | $conn_w, | ||||
| 'DELETE FROM %T WHERE epoch < %d LIMIT 100', | 'DELETE FROM %T WHERE epoch < %d LIMIT 100', | ||||
| $table->getTableName(), | $table->getTableName(), | ||||
| time() - $ttl); | $this->getGarbageEpoch()); | ||||
| return ($conn_w->getAffectedRows() == 100); | return ($conn_w->getAffectedRows() == 100); | ||||
| } | } | ||||
| } | } | ||||