Merge pull request #1739 from MPOS/notification-cleanup
[ADDED] Notification cleanup script
This commit is contained in:
commit
682beb60d1
@ -10,7 +10,7 @@
|
|||||||
PHP_BIN=$( which php )
|
PHP_BIN=$( which php )
|
||||||
|
|
||||||
# List of cruns to execute
|
# 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
|
# Output additional runtime information
|
||||||
VERBOSE="0"
|
VERBOSE="0"
|
||||||
|
|||||||
@ -10,7 +10,7 @@
|
|||||||
PHP_BIN=$( which php )
|
PHP_BIN=$( which php )
|
||||||
|
|
||||||
# List of cruns to execute
|
# 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
|
# Output additional runtime information
|
||||||
VERBOSE="0"
|
VERBOSE="0"
|
||||||
|
|||||||
@ -151,6 +151,27 @@ class Notification extends Mail {
|
|||||||
$this->setErrorMessage('Error sending mail notification');
|
$this->setErrorMessage('Error sending mail notification');
|
||||||
return false;
|
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();
|
$notification = new Notification();
|
||||||
|
|||||||
@ -390,6 +390,12 @@ $aSettings['monitoring'][] = array(
|
|||||||
'name' => 'monitoring_uptimerobot_api_keys', 'value' => $setting->getValue('monitoring_uptimerobot_api_keys'),
|
'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.'
|
'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(
|
$aSettings['notifications'][] = array(
|
||||||
'display' => 'Disable notifications', 'type' => 'select',
|
'display' => 'Disable notifications', 'type' => 'select',
|
||||||
'options' => array( 0 => 'No', 1 => 'Yes' ),
|
'options' => array( 0 => 'No', 1 => 'Yes' ),
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
// Small helper array that may be used on some page controllers to
|
// Small helper array that may be used on some page controllers to
|
||||||
// fetch the crons we wish to monitor
|
// 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']) {
|
switch ($config['payout_system']) {
|
||||||
case 'pplns':
|
case 'pplns':
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user