Page MenuHomePhabricator

D14197.diff
No OneTemporary

D14197.diff

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

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)

Event Timeline