Minor work on Task
This commit is contained in:
parent
317cc331ae
commit
ac4ad76886
@ -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',
|
||||
))
|
||||
);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
76
modules/task/classes/Task/Task/Clean.php
Normal file
76
modules/task/classes/Task/Task/Clean.php
Normal file
@ -0,0 +1,76 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* Delete old data from the TASK_LOG
|
||||
*
|
||||
* @package Task
|
||||
* @category Tasks
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Task_Task_Clean extends Minion_Task {
|
||||
// @todo This needs to be more dynamic, without hard coding task_ids or messages.
|
||||
protected function _execute(array $params) {
|
||||
$tl = ORM::factory('Task_Log');
|
||||
$delay = 86400*2;
|
||||
|
||||
foreach ($tl->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();
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user