public static function Notifications_Queue::event_clean in Notifications 6.4
Clean up event table. Drop expired events for which we don't have pending rows.
Parameters
$update: Update event counter
2 calls to Notifications_Queue::event_clean()
- Notifications_Queue::process_clean in includes/
notifications_queue.class.inc - Clean up queue and events before starting process
- Notifications_Queue::queue_clean in includes/
notifications_queue.class.inc - Clean queue for a user and update event tracker
File
- includes/
notifications_queue.class.inc, line 813
Class
- Notifications_Queue
- Queue management and processing
Code
public static function event_clean($update = FALSE) {
// This expiretime will prevent some race condition that occurs when the event is saved but the subs queue not yet populated
$expiretime = time() - 60;
if ($update) {
// Update event counter, which keeps the number of notifications pending for each event
db_query("UPDATE {notifications_event} e SET counter = (SELECT COUNT(*) FROM {notifications_queue} q WHERE q.eid = e.eid ) WHERE e.created < %d", $expiretime);
}
db_query("DELETE FROM {notifications_event} WHERE counter = 0 AND created < %d", $expiretime);
// Delete events with no pending notifications. As events are created sequentially, we use this fact to speed up the query
db_query("DELETE FROM {notifications_event} WHERE created < %d AND eid < (SELECT MIN(eid) FROM {notifications_queue})", $expiretime);
}