Merge pull request #1739 from MPOS/notification-cleanup

[ADDED] Notification cleanup script
This commit is contained in:
Sebastian Grewe 2014-02-14 08:56:51 +01:00
commit 682beb60d1
5 changed files with 30 additions and 3 deletions

View File

@ -10,7 +10,7 @@
PHP_BIN=$( which php )
# List of cruns to execute
CRONS="findblock.php proportional_payout.php pplns_payout.php pps_payout.php blockupdate.php payouts.php tickerupdate.php notifications.php statistics.php token_cleanup.php archive_cleanup.php liquid_payout.php"
CRONS="findblock.php proportional_payout.php pplns_payout.php pps_payout.php blockupdate.php payouts.php tickerupdate.php notifications.php statistics.php token_cleanup.php archive_cleanup.php notification_cleanup.php liquid_payout.php"
# Output additional runtime information
VERBOSE="0"

View File

@ -10,7 +10,7 @@
PHP_BIN=$( which php )
# List of cruns to execute
CRONS="tickerupdate.php notifications.php token_cleanup.php archive_cleanup.php"
CRONS="tickerupdate.php notifications.php token_cleanup.php archive_cleanup.php notification_cleanup.php"
# Output additional runtime information
VERBOSE="0"

View File

@ -151,6 +151,27 @@ class Notification extends Mail {
$this->setErrorMessage('Error sending mail notification');
return false;
}
/**
* Cleanup old notifications
* @param none
* @return bool true or false
**/
public function cleanupNotifications($days=7) {
$failed = 0;
$this->deleted = 0;
$stmt = $this->mysqli->prepare("DELETE FROM $this->table WHERE time < (NOW() - ? * 24 * 60 * 60)");
if (! ($this->checkStmt($stmt) && $stmt->bind_param('i', $days) && $stmt->execute())) {
$failed++;
} else {
$this->deleted += $stmt->affected_rows;
}
if ($failed > 0) {
$this->setCronMessage('Failed to delete ' . $failed . ' notifications from ' . $this->table . ' table');
return false;
}
return true;
}
}
$notification = new Notification();

View File

@ -390,6 +390,12 @@ $aSettings['monitoring'][] = array(
'name' => 'monitoring_uptimerobot_api_keys', 'value' => $setting->getValue('monitoring_uptimerobot_api_keys'),
'tooltip' => 'Create per-monitor API keys and save them here to propagate your uptime statistics.'
);
$aSettings['notifications'][] = array(
'display' => 'Notification Cleanup Time', 'type' => 'text',
'default' => 7,
'name' => 'notifications_cleanup_time', 'value' => $setting->getValue('notifications_cleanup_time'),
'tooltip' => 'Maximum age in days of notifications before cleaned from database.'
);
$aSettings['notifications'][] = array(
'display' => 'Disable notifications', 'type' => 'select',
'options' => array( 0 => 'No', 1 => 'Yes' ),

View File

@ -2,7 +2,7 @@
// Small helper array that may be used on some page controllers to
// fetch the crons we wish to monitor
$aMonitorCrons = array('statistics','payouts','token_cleanup','archive_cleanup','blockupdate','findblock','notifications','tickerupdate','liquid_payout');
$aMonitorCrons = array('statistics','payouts','token_cleanup','archive_cleanup','notification_cleanup','blockupdate','findblock','notifications','tickerupdate','liquid_payout');
switch ($config['payout_system']) {
case 'pplns':