Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14357606
D14197.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D14197.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -845,6 +845,7 @@
'DrydockLeaseWorker' => 'applications/drydock/worker/DrydockLeaseWorker.php',
'DrydockLog' => 'applications/drydock/storage/DrydockLog.php',
'DrydockLogController' => 'applications/drydock/controller/DrydockLogController.php',
+ 'DrydockLogGarbageCollector' => 'applications/drydock/garbagecollector/DrydockLogGarbageCollector.php',
'DrydockLogListController' => 'applications/drydock/controller/DrydockLogListController.php',
'DrydockLogListView' => 'applications/drydock/view/DrydockLogListView.php',
'DrydockLogQuery' => 'applications/drydock/query/DrydockLogQuery.php',
@@ -4586,6 +4587,7 @@
'PhabricatorPolicyInterface',
),
'DrydockLogController' => 'DrydockController',
+ 'DrydockLogGarbageCollector' => 'PhabricatorGarbageCollector',
'DrydockLogListController' => 'DrydockLogController',
'DrydockLogListView' => 'AphrontView',
'DrydockLogQuery' => 'DrydockQuery',
diff --git a/src/applications/drydock/garbagecollector/DrydockLogGarbageCollector.php b/src/applications/drydock/garbagecollector/DrydockLogGarbageCollector.php
new file mode 100644
--- /dev/null
+++ b/src/applications/drydock/garbagecollector/DrydockLogGarbageCollector.php
@@ -0,0 +1,22 @@
+<?php
+
+final class DrydockLogGarbageCollector
+ extends PhabricatorGarbageCollector {
+
+ public function collectGarbage() {
+ $log_table = new DrydockLog();
+ $conn_w = $log_table->establishConnection('w');
+
+ $now = PhabricatorTime::getNow();
+ $ttl = phutil_units('30 days in seconds');
+
+ queryfx(
+ $conn_w,
+ 'DELETE FROM %T WHERE epoch <= %d LIMIT 100',
+ $log_table->getTableName(),
+ $now - $ttl);
+
+ return ($conn_w->getAffectedRows() == 100);
+ }
+
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Dec 21, 5:56 AM (17 h, 41 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6912960
Default Alt Text
D14197.diff (1 KB)
Attached To
Mode
D14197: Garbage collect Drydock logs after 30 days
Attached
Detach File
Event Timeline
Log In to Comment