From ac4ad76886220a653f3271e2d1cfd736b783ebac Mon Sep 17 00:00:00 2001 From: Deon George Date: Thu, 10 Oct 2013 12:13:29 +1100 Subject: [PATCH] Minor work on Task --- .../task/classes/Controller/Admin/Task.php | 25 +++--- modules/task/classes/Task/Task/Clean.php | 76 +++++++++++++++++++ 2 files changed, 88 insertions(+), 13 deletions(-) create mode 100644 modules/task/classes/Task/Task/Clean.php diff --git a/modules/task/classes/Controller/Admin/Task.php b/modules/task/classes/Controller/Admin/Task.php index 9aa28c30..7bb9208b 100644 --- a/modules/task/classes/Controller/Admin/Task.php +++ b/modules/task/classes/Controller/Admin/Task.php @@ -22,19 +22,18 @@ class Controller_Admin_Task extends Controller_Task { public function action_log() { Block::factory() ->title(_('Task Log')) - ->body(Table::display( - ORM::factory('Task_Log')->find_all(), - 25, - array( - 'id'=>array('label'=>'ID','url'=>URL::link('admin','task/view/')), - 'date_orig'=>array('label'=>'Date'), - 'task->display("name")'=>array('label'=>'Task'), - 'result'=>array('label'=>'Result'), - 'message'=>array('label'=>'Message'), - ), - array( - 'page'=>TRUE, - ))); + ->title_icon('icon-th-list') + ->body(Table::factory() + ->page_items(50) + ->data(ORM::factory('Task_Log')->find_all()) + ->columns(array( + 'id'=>'ID', + 'date_orig'=>'Date', + 'task->display("name")'=>'Task', + 'result'=>'Result', + 'message'=>'Message', + )) + ); } } ?> diff --git a/modules/task/classes/Task/Task/Clean.php b/modules/task/classes/Task/Task/Clean.php new file mode 100644 index 00000000..67be814a --- /dev/null +++ b/modules/task/classes/Task/Task/Clean.php @@ -0,0 +1,76 @@ +find_all() as $to) { + // Delete Task already running messages. + if (preg_match('/^Task\ [0-9]+\ is already running$/',$to->message) AND $to->date_orig < time()+$delay) { + $to->delete(); + continue; + } + + // Delete Empty Invoices Sent + if (preg_match('/^Invoices Sent:\s+$/',$to->message) AND $to->date_orig < time()+$delay) { + $to->delete(); + continue; + } + + // Delete Overdue Notes Sent + if (preg_match('/^OverDue Notice #[0-9] Reminders Sent:\s+$/',$to->message) AND $to->date_orig < time()+$delay) { + $to->delete(); + continue; + } + + // Over Notes Sent + if (preg_match('/^(Overdue|Due) Reminders Sent:\s+$/',$to->message) AND $to->date_orig < time()+$delay) { + $to->delete(); + continue; + } + + // Services Invoiced + if (preg_match('/^Services Invoiced:\s+$/',$to->message) AND $to->date_orig < time()+$delay) { + $to->delete(); + continue; + } + + if (in_array($to->task_id,array(2,4,13)) AND $to->date_orig < time()+$delay) { + $to->delete(); + continue; + } + + if (in_array($to->task_id,array(3)) AND $to->date_orig < time()+86400*60) { + $to->delete(); + continue; + } + + // Errors + if ((preg_match('/ErrorException\s+/',$to->message) + OR preg_match('/^The requested URL\s+/',$to->message) + OR preg_match('/^Unable to find a route to match the URI:/',$to->message) + OR preg_match('/View_Exception\s+/',$to->message) + OR preg_match('/Kohana_Exception\s+/',$to->message)) + + AND $to->date_orig < time()+$delay) { + + $to->delete(); + continue; + } +continue; +print_r(array($to->object(),$to->display('date_orig')));die(); + } + } +} +?>