mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-19 03:50:54 +01:00
Garbage collect old notifications
Summary: Fixes T8473. Adds garbage collection to the `phabricator_feed.feed_storynotification` table. Test Plan: Reduced the TTL to a really small value and ran the trigger daemon. Saw feed notifications removed from the database. Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: epriestley, Korvin Maniphest Tasks: T8473 Differential Revision: https://secure.phabricator.com/D13233
This commit is contained in:
parent
72fc3da416
commit
5a00b5f6f6
3 changed files with 27 additions and 0 deletions
|
@ -763,6 +763,7 @@ phutil_register_library_map(array(
|
|||
'FeedPublisherWorker' => 'applications/feed/worker/FeedPublisherWorker.php',
|
||||
'FeedPushWorker' => 'applications/feed/worker/FeedPushWorker.php',
|
||||
'FeedQueryConduitAPIMethod' => 'applications/feed/conduit/FeedQueryConduitAPIMethod.php',
|
||||
'FeedStoryNotificationGarbageCollector' => 'applications/notification/garbagecollector/FeedStoryNotificationGarbageCollector.php',
|
||||
'FileAllocateConduitAPIMethod' => 'applications/files/conduit/FileAllocateConduitAPIMethod.php',
|
||||
'FileConduitAPIMethod' => 'applications/files/conduit/FileConduitAPIMethod.php',
|
||||
'FileCreateMailReceiver' => 'applications/files/mail/FileCreateMailReceiver.php',
|
||||
|
@ -4048,6 +4049,7 @@ phutil_register_library_map(array(
|
|||
'FeedPublisherWorker' => 'FeedPushWorker',
|
||||
'FeedPushWorker' => 'PhabricatorWorker',
|
||||
'FeedQueryConduitAPIMethod' => 'FeedConduitAPIMethod',
|
||||
'FeedStoryNotificationGarbageCollector' => 'PhabricatorGarbageCollector',
|
||||
'FileAllocateConduitAPIMethod' => 'FileConduitAPIMethod',
|
||||
'FileConduitAPIMethod' => 'ConduitAPIMethod',
|
||||
'FileCreateMailReceiver' => 'PhabricatorMailReceiver',
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
final class FeedStoryNotificationGarbageCollector
|
||||
extends PhabricatorGarbageCollector {
|
||||
|
||||
public function collectGarbage() {
|
||||
$ttl = 90 * 24 * 60 * 60;
|
||||
|
||||
$table = new PhabricatorFeedStoryNotification();
|
||||
$conn_w = $table->establishConnection('w');
|
||||
|
||||
queryfx(
|
||||
$conn_w,
|
||||
'DELETE FROM %T WHERE chronologicalKey < (%d << 32)
|
||||
ORDER BY chronologicalKey ASC LIMIT 100',
|
||||
$table->getTableName(),
|
||||
time() - $ttl);
|
||||
|
||||
return ($conn_w->getAffectedRows() == 100);
|
||||
}
|
||||
|
||||
}
|
|
@ -28,6 +28,9 @@ final class PhabricatorFeedStoryNotification extends PhabricatorFeedDAO {
|
|||
'key_object' => array(
|
||||
'columns' => array('primaryObjectPHID'),
|
||||
),
|
||||
'key_chronological' => array(
|
||||
'columns' => array('chronologicalKey'),
|
||||
),
|
||||
),
|
||||
) + parent::getConfiguration();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue