calculate as max per stats cron invocation. Part of MDL-16709 ; merged from 19_STABLE
$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();
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'),
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));
$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 <b>the first time</b> 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 <b>start</b>? 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.';
$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';
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;
}
// 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