Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14837358
D14197.id.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.id.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, Feb 1, 8:37 AM (16 h, 51 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7081290
Default Alt Text
D14197.id.diff (1 KB)
Attached To
Mode
D14197: Garbage collect Drydock logs after 30 days
Attached
Detach File
Event Timeline
Log In to Comment