diff --git a/resources/sql/autopatches/20140201.gc.1.mailsent.sql b/resources/sql/autopatches/20140201.gc.1.mailsent.sql new file mode 100644 index 0000000000..21254ca890 --- /dev/null +++ b/resources/sql/autopatches/20140201.gc.1.mailsent.sql @@ -0,0 +1,2 @@ +ALTER TABLE {$NAMESPACE}_metamta.metamta_mail + ADD KEY `key_created` (dateCreated); diff --git a/resources/sql/autopatches/20140201.gc.2.mailreceived.sql b/resources/sql/autopatches/20140201.gc.2.mailreceived.sql new file mode 100644 index 0000000000..e9de922182 --- /dev/null +++ b/resources/sql/autopatches/20140201.gc.2.mailreceived.sql @@ -0,0 +1,2 @@ +ALTER TABLE {$NAMESPACE}_metamta.metamta_receivedmail + ADD KEY `key_created` (dateCreated); diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 2692f975ce..0e9fc51898 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -923,6 +923,8 @@ phutil_register_library_map(array( 'ManiphestTransactionSaveController' => 'applications/maniphest/controller/ManiphestTransactionSaveController.php', 'ManiphestView' => 'applications/maniphest/view/ManiphestView.php', 'MetaMTAConstants' => 'applications/metamta/constants/MetaMTAConstants.php', + 'MetaMTAMailReceivedGarbageCollector' => 'applications/metamta/garbagecollector/MetaMTAMailReceivedGarbageCollector.php', + 'MetaMTAMailSentGarbageCollector' => 'applications/metamta/garbagecollector/MetaMTAMailSentGarbageCollector.php', 'MetaMTANotificationType' => 'applications/metamta/constants/MetaMTANotificationType.php', 'MetaMTAReceivedMailStatus' => 'applications/metamta/constants/MetaMTAReceivedMailStatus.php', 'NuanceCapabilitySourceDefaultEdit' => 'applications/nuance/capability/NuanceCapabilitySourceDefaultEdit.php', @@ -3513,6 +3515,8 @@ phutil_register_library_map(array( 'ManiphestTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 'ManiphestTransactionSaveController' => 'ManiphestController', 'ManiphestView' => 'AphrontView', + 'MetaMTAMailReceivedGarbageCollector' => 'PhabricatorGarbageCollector', + 'MetaMTAMailSentGarbageCollector' => 'PhabricatorGarbageCollector', 'MetaMTANotificationType' => 'MetaMTAConstants', 'MetaMTAReceivedMailStatus' => 'MetaMTAConstants', 'NuanceCapabilitySourceDefaultEdit' => 'PhabricatorPolicyCapability', diff --git a/src/applications/metamta/garbagecollector/MetaMTAMailReceivedGarbageCollector.php b/src/applications/metamta/garbagecollector/MetaMTAMailReceivedGarbageCollector.php new file mode 100644 index 0000000000..02911354b5 --- /dev/null +++ b/src/applications/metamta/garbagecollector/MetaMTAMailReceivedGarbageCollector.php @@ -0,0 +1,21 @@ +establishConnection('w'); + + queryfx( + $conn_w, + 'DELETE FROM %T WHERE dateCreated < %d LIMIT 100', + $table->getTableName(), + time() - $ttl); + + return ($conn_w->getAffectedRows() == 100); + } + +} diff --git a/src/applications/metamta/garbagecollector/MetaMTAMailSentGarbageCollector.php b/src/applications/metamta/garbagecollector/MetaMTAMailSentGarbageCollector.php new file mode 100644 index 0000000000..b4d4b05b76 --- /dev/null +++ b/src/applications/metamta/garbagecollector/MetaMTAMailSentGarbageCollector.php @@ -0,0 +1,21 @@ +establishConnection('w'); + + queryfx( + $conn_w, + 'DELETE FROM %T WHERE dateCreated < %d LIMIT 100', + $table->getTableName(), + time() - $ttl); + + return ($conn_w->getAffectedRows() == 100); + } + +}