Skip to content
Snippets Groups Projects
Commit 2204bb39 authored by Justus Dieckmann's avatar Justus Dieckmann Committed by Tobias Reischmann
Browse files

Add task that cleans up old delays

parent 0158ff5c
No related branches found
No related tags found
No related merge requests found
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Scheduled task for cleanup past delays
*
* @package tool_lifecycle
* @copyright 2019 Justus Dieckmann WWU
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace tool_lifecycle\task;
defined('MOODLE_INTERNAL') || die;
/**
* Scheduled task for cleanup past delays
*
* @package tool_lifecycle
* @copyright 2019 Justus Dieckmann WWU
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class lifecycle_cleanup_task extends \core\task\scheduled_task {
/**
* Get a descriptive name for this task (shown to admins).
*
* @return string
* @throws \coding_exception
*/
public function get_name() {
return get_string('lifecycle_cleanup_task', 'tool_lifecycle');
}
/**
* Do the job.
*/
public function execute() {
global $DB;
$twomonthago = time() - 60 * 24 * 60 * 60;
$DB->delete_records_select('tool_lifecycle_delayed', 'delayeduntil <= :time', array('time' => $twomonthago));
$DB->delete_records_select('tool_lifecycle_delayed_workf', 'delayeduntil <= :time', array('time' => $twomonthago));
}
}
\ No newline at end of file
......@@ -35,5 +35,14 @@ $tasks = array(
'month' => '*',
'dayofweek' => '*',
'faildelay' => 1,
),
array(
'classname' => 'tool_lifecycle\task\lifecycle_cleanup_task',
'blocking' => 0,
'minute' => '0',
'hour' => '4',
'day' => '*',
'month' => '*',
'dayofweek' => '0',
)
);
\ No newline at end of file
......@@ -60,6 +60,7 @@ $string['cannot_trigger_workflow_manually'] = 'The requested workflow could not
$string['error_wrong_trigger_selected'] = 'You tried to request a non-manual trigger.';
$string['lifecycle_task'] = 'Run the life cycle processes';
$string['lifecycle_cleanup_task'] = 'Runs the life cycle cleanup';
$string['trigger_subpluginname'] = 'Subplugin name';
$string['trigger_subpluginname_help'] = 'Step subplugin/trigger title (visible for admins only).';
......
......@@ -25,7 +25,7 @@
defined('MOODLE_INTERNAL') || die;
$plugin->maturity = MATURITY_BETA;
$plugin->version = 2019102900;
$plugin->version = 2019103100;
$plugin->component = 'tool_lifecycle';
$plugin->requires = 2017111300; // Require Moodle 3.4 (or above).
$plugin->release = 'v3.7-r1';
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment