Differential D14219 Diff 34352 src/applications/notification/garbagecollector/FeedStoryNotificationGarbageCollector.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/notification/garbagecollector/FeedStoryNotificationGarbageCollector.php
| <?php | <?php | ||||
| final class FeedStoryNotificationGarbageCollector | final class FeedStoryNotificationGarbageCollector | ||||
| extends PhabricatorGarbageCollector { | extends PhabricatorGarbageCollector { | ||||
| const COLLECTORCONST = 'feed.notifications'; | const COLLECTORCONST = 'feed.notifications'; | ||||
| public function getCollectorName() { | public function getCollectorName() { | ||||
| return pht('Notifications'); | return pht('Notifications'); | ||||
| } | } | ||||
| public function getDefaultRetentionPolicy() { | public function getDefaultRetentionPolicy() { | ||||
| return phutil_units('90 days in seconds'); | return phutil_units('90 days in seconds'); | ||||
| } | } | ||||
| public function collectGarbage() { | protected function collectGarbage() { | ||||
| $ttl = 90 * 24 * 60 * 60; | |||||
| $table = new PhabricatorFeedStoryNotification(); | $table = new PhabricatorFeedStoryNotification(); | ||||
| $conn_w = $table->establishConnection('w'); | $conn_w = $table->establishConnection('w'); | ||||
| queryfx( | queryfx( | ||||
| $conn_w, | $conn_w, | ||||
| 'DELETE FROM %T WHERE chronologicalKey < (%d << 32) | 'DELETE FROM %T WHERE chronologicalKey < (%d << 32) | ||||
| ORDER BY chronologicalKey ASC LIMIT 100', | ORDER BY chronologicalKey ASC LIMIT 100', | ||||
| $table->getTableName(), | $table->getTableName(), | ||||
| time() - $ttl); | $this->getGarbageEpoch()); | ||||
| return ($conn_w->getAffectedRows() == 100); | return ($conn_w->getAffectedRows() == 100); | ||||
| } | } | ||||
| } | } | ||||