Triggered actions should be deleted automatically after a certain period of time.

function scheduled_actions_cron() {
 ...
  $max = REQUEST_TIME - variable_get('scheduled_actions_archive_day_limit', 1) * 86400; //24*60*60
  db_delete('scheduled_actions')
    ->condition('triggered', 0, '>')
    ->condition('triggered', $max, '<=')
    ->execute();

Comments

slashrsm’s picture

Status: Active » Needs work

That sounds like a reasonable feature. I think we should expose this also in administration page to allow user to set 'scheduled_actions_archive_day_limit' and also to enable/disable this feature. What do you think?

pasqualle’s picture

Yes, I agree,
zero should mean disabled..

something like

  $form['scheduled_actions_archive_day_limit'] = array(
    '#type' => 'select',
    '#title' => t('Triggered actions log'),
    '#default_value' => variable_get('scheduled_actions_archive_day_limit', 1),
    '#options' => array(
      0 => t('Do not delete'),
      1 => t('Delete after 1 day'),
      7 => t('Delete after 1 week'),
      30 => t('Delete after 30 days'),
    )
    '#description' => t('The maximum days to keep triggered actions archived. Requires a <a href="@cron">cron maintenance task</a>.', array('@cron' => url('admin/reports/status')))
  );

and at cron check for zero first..

slashrsm’s picture

Assigned: Unassigned » slashrsm
Status: Needs work » Needs review
StatusFileSize
new2.54 KB

Attached patch implements it. Can you review it?

pasqualle’s picture

I did not test it, but the patch looks good..

paranojik’s picture

Would not apply on latest dev. Reapplied. Also fixed some minor coding style issues and removed trailing spaces.

Thanks @primsi for testing this.

slashrsm’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.