MDL-14208 "add cron routine to clean up cache records"
This commit is contained in:
@@ -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;
|
||||
}
|
||||
?>
|
||||
@@ -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,4 +1,4 @@
|
||||
<?php
|
||||
$plugin->version = 2008072400; // The (date) version of this module
|
||||
$plugin->version = 2008072401; // The (date) version of this module
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user