function _advancedqueue_purge_history in Advanced Queue 7
Helper function to remove data we don't need anymore.
Removes old entries of processed items.
1 call to _advancedqueue_purge_history()
- _advancedqueue_cleanup_table in ./
advancedqueue.module - Helper function to clean the advancedqueue table.
File
- ./
advancedqueue.module, line 328 - Helper module for advanced queuing.
Code
function _advancedqueue_purge_history($preserve_rows) {
// Item status we want to clean.
$statuses = array(
ADVANCEDQUEUE_STATUS_SUCCESS,
ADVANCEDQUEUE_STATUS_FAILURE,
);
// Find the timestamp of the Xth row.
$delete_before = db_select('advancedqueue', 'a')
->fields('a', array(
'created',
))
->condition('status', $statuses, 'IN')
->orderBy('created', 'DESC')
->range($preserve_rows - 1, 1)
->execute()
->fetchField();
// Remove all items created before the selected timestamp.
if ($delete_before) {
db_delete('advancedqueue')
->condition('created', $delete_before, '<')
->condition('status', $statuses, 'IN')
->execute();
}
}