MDL-14208 "add cron routine to clean up cache records"

This commit is contained in:
jamiesensei
2008-07-24 17:45:01 +00:00
parent d1789d5d64
commit 9859e26cc0
3 changed files with 36 additions and 1 deletions
+15
View File
@@ -0,0 +1,15 @@
<?php // $Id$
function quiz_report_statistics_cron(){
global $DB;
if ($todelete = $DB->get_records_select_menu('quiz_statistics', 'timemodified < ?', array(time()-5*HOURSECS))){
list($todeletesql, $todeleteparams) = $DB->get_in_or_equal($todelete);
if (!$DB->delete_records_select('quiz_statistics', "id $todeletesql", $todeleteparams)){
mtrace('Error deleting out of date quiz_statistics records.');
}
if (!$DB->delete_records_select('quiz_question_statistics', "quizstatisticsid $todeletesql", $todeleteparams)){
mtrace('Error deleting out of date quiz_question_statistics records.');
}
}
return true;
}
?>
+20
View File
@@ -0,0 +1,20 @@
<?php // $Id$
function xmldb_quizreport_statistics_upgrade($oldversion=0) {
global $DB;
$dbman = $DB->get_manager();
$result = true;
//===== 1.9.0 upgrade line ======//
if ($result && $oldversion < 2008072401) {
//register cron to run every 5 hours.
$result = $result && $DB->set_field('quiz_report', 'cron', HOURSECS*5, array('name'=>'statistics'));
}
return $result;
}
?>
+1 -1
View File
@@ -1,4 +1,4 @@
<?php
$plugin->version = 2008072400; // The (date) version of this module
$plugin->version = 2008072401; // The (date) version of this module
?>