1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-02-02 01:48:23 +01:00
phorge-phorge/src/applications/metamta/garbagecollector/MetaMTAMailReceivedGarbageCollector.php
epriestley 878a493301 Begin standardizing garbage collectors
Summary: Ref T9494. Improve support infrastructure for garbage collectors.

Test Plan:
  - Ran `bin/phd debug trigger`, saw collectors execute.

{F857852}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9494

Differential Revision: https://secure.phabricator.com/D14218
2015-10-01 16:58:43 -07:00

31 lines
699 B
PHP

<?php
final class MetaMTAMailReceivedGarbageCollector
extends PhabricatorGarbageCollector {
const COLLECTORCONST = 'metamta.received';
public function getCollectorName() {
return pht('Mail (Received)');
}
public function getDefaultRetentionPolicy() {
return phutil_units('90 days in seconds');
}
public function collectGarbage() {
$ttl = phutil_units('90 days in seconds');
$table = new PhabricatorMetaMTAReceivedMail();
$conn_w = $table->establishConnection('w');
queryfx(
$conn_w,
'DELETE FROM %T WHERE dateCreated < %d LIMIT 100',
$table->getTableName(),
time() - $ttl);
return ($conn_w->getAffectedRows() == 100);
}
}