From: stronk7 Date: Mon, 13 Oct 2008 21:53:49 +0000 (+0000) Subject: Adding new setting "statsruntimedays" to configure the number of days to X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=5e7206a8f65c22134d5699210520b18abba7a917;p=moodle.git Adding new setting "statsruntimedays" to configure the number of days to calculate as max per stats cron invocation. Part of MDL-16709 ; merged from 19_STABLE --- diff --git a/admin/cron.php b/admin/cron.php index c90d28b57c..784f3022ce 100644 --- a/admin/cron.php +++ b/admin/cron.php @@ -497,8 +497,9 @@ $timetocheck = stats_get_base_daily() + $CFG->statsruntimestarthour*60*60 + $CFG->statsruntimestartminute*60; if (time() > $timetocheck) { - // process max 31 days per cron execution - if (stats_cron_daily(31)) { + // process configured number of days as max (defaulting to 31) + $maxdays = empty($CFG->statsruntimedays) ? 31 : abs($CFG->statsruntimedays); + if (stats_cron_daily($maxdays)) { if (stats_cron_weekly()) { if (stats_cron_monthly()) { stats_clean_old(); diff --git a/admin/settings/server.php b/admin/settings/server.php index 296eb87558..7fdb9f5c52 100644 --- a/admin/settings/server.php +++ b/admin/settings/server.php @@ -116,7 +116,7 @@ $temp->add(new admin_setting_configselect('statsfirstrun', get_string('statsfirs 60*60*24*140 => get_string('nummonths','moodle',5), 60*60*24*168 => get_string('nummonths','moodle',6), 'all' => get_string('all') ))); -$temp->add(new admin_setting_configselect('statsmaxruntime', get_string('statsmaxruntime', 'admin'), get_string('configstatsmaxruntime2', 'admin'), 0, array(0 => get_string('untilcomplete'), +$temp->add(new admin_setting_configselect('statsmaxruntime', get_string('statsmaxruntime', 'admin'), get_string('configstatsmaxruntime3', 'admin'), 0, array(0 => get_string('untilcomplete'), 60*30 => '10 '.get_string('minutes'), 60*30 => '30 '.get_string('minutes'), 60*60 => '1 '.get_string('hour'), @@ -127,6 +127,7 @@ $temp->add(new admin_setting_configselect('statsmaxruntime', get_string('statsma 60*60*6 => '6 '.get_string('hours'), 60*60*7 => '7 '.get_string('hours'), 60*60*8 => '8 '.get_string('hours') ))); +$temp->add(new admin_setting_configtext('statsruntimedays', get_string('statsruntimedays', 'admin'), get_string('configstatsruntimedays', 'admin'), 31, PARAM_INT)); $temp->add(new admin_setting_configtime('statsruntimestarthour', 'statsruntimestartminute', get_string('statsruntimestart', 'admin'), get_string('configstatsruntimestart', 'admin'), array('h' => 0, 'm' => 0))); $temp->add(new admin_setting_configtext('statsuserthreshold', get_string('statsuserthreshold', 'admin'), get_string('configstatsuserthreshold', 'admin'), 0, PARAM_INT)); diff --git a/lang/en_utf8/admin.php b/lang/en_utf8/admin.php index 7d7ed1814c..07d1e9901c 100644 --- a/lang/en_utf8/admin.php +++ b/lang/en_utf8/admin.php @@ -240,7 +240,9 @@ $string['configstartwday'] = 'Start of Week'; $string['configstatscatdepth'] = 'Statistics code uses simplified course enrolment logic, overrides are ignored and there is a maximum number of verified parent course categories. Number 0 means detect only direct role assignments on site and course level, 1 means detect also role assignments in parent category of course, etc. Higher numbers result in much higher database server load during stats processing.'; $string['configstatsfirstrun'] = 'This specifies how far back the logs should be processed the first time the cronjob wants to process statistics. If you have a lot of traffic and are on shared hosting, it\'s probably not a good idea to go too far back, as it could take a long time to run and be quite resource intensive. (Note that for this setting, 1 month = 28 days. In the graphs and reports generated, 1 month = 1 calendar month.)'; $string['configstatsmaxruntime'] = 'Stats processing can be quite intensive, so use a combination of this field and the next one to specify when it will run and how long for.'; -$string['configstatsmaxruntime2'] = 'Stats processing can be quite intensive, specify maximum time allowed for gathering of one day of statistics. Maximum number of days processed in one cron execution is 3.'; +$string['configstatsmaxruntime2'] = 'Stats processing can be quite intensive, specify maximum time allowed for gathering of one day of statistics. Maximum number of days processed in one cron execution is 31.'; +$string['configstatsmaxruntime3'] = 'Specify the maximum time allowed to calculate the statistics for one day, bearing in mind that stats processing can put a big load on the server. The maximum number of days processed in one cron can be specified below.'; +$string['configstatsruntimedays'] = 'Specify the maximum number of days processed in each stats execution. When stats are up-to-date, only one day will be processed, so adjust this value depending of your server load, reducing it if shorter cron executions are needed.'; $string['configstatsruntimestart'] = 'What time should the cronjob that does the stats processing start? Please specify different times if there are multiple Moodles on one physical server.'; $string['configstatsuserthreshold'] = 'If you enter a non-zero, non numeric value here, for ranking courses, courses with less than this number of enrolled users (all roles) will be ignored'; $string['configstripalltitletags'] = 'Uncheck this setting to allow HTML tags in activity and resource names.'; @@ -705,6 +707,7 @@ $string['stats'] = 'Statistics'; $string['statscatdepth'] = 'Maximum parent categories'; $string['statsfirstrun'] = 'Maximum processing interval'; $string['statsmaxruntime'] = 'Maximum runtime'; +$string['statsruntimedays'] = 'Days to process'; $string['statsruntimestart'] = 'Run at'; $string['statsuserthreshold'] = 'User threshold'; $string['stickyblocks'] = 'Sticky blocks'; diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index b79ad6d58a..862e8e5a73 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -862,6 +862,15 @@ function xmldb_main_upgrade($oldversion) { upgrade_main_savepoint($result, 2008101000); } + if ($result && $oldversion < 2008101300) { + + if (!get_config(NULL, 'statsruntimedays')) { + set_config('statsruntimedays', '31'); + } + + /// Main savepoint reached + upgrade_main_savepoint($result, 2008101300); + } return $result; } diff --git a/version.php b/version.php index dfd1dd043a..d596850846 100644 --- a/version.php +++ b/version.php @@ -6,7 +6,7 @@ // This is compared against the values stored in the database to determine // whether upgrades should be performed (see lib/db/*.php) - $version = 2008101000; // YYYYMMDD = date of the last version bump + $version = 2008101300; // YYYYMMDD = date of the last version bump // XX = daily increments $release = '2.0 dev (Build: 20081013)'; // Human-friendly version name