Skip to content

Commit

Permalink
Adding new setting "statsruntimedays" to configure the number
Browse files Browse the repository at this point in the history
of days to calculate as max per stats cron invocation. Part of MDL-16709
  • Loading branch information
stronk7 committed Oct 13, 2008
1 parent 8c5ea44 commit a1fb046
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
5 changes: 3 additions & 2 deletions admin/cron.php
Expand Up @@ -463,8 +463,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();
Expand Down
3 changes: 2 additions & 1 deletion admin/settings/server.php
Expand Up @@ -123,7 +123,7 @@
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'),
Expand All @@ -134,6 +134,7 @@
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));

Expand Down
5 changes: 4 additions & 1 deletion lang/en_utf8/admin.php
Expand Up @@ -230,7 +230,9 @@
$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.';
Expand Down Expand Up @@ -668,6 +670,7 @@
$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';
Expand Down
6 changes: 6 additions & 0 deletions lib/db/upgrade.php
Expand Up @@ -3067,6 +3067,12 @@ function xmldb_main_upgrade($oldversion=0) {
upgrade_main_savepoint($result, 2007101526);
}

if ($result && $oldversion < 2007101527) {
if (!get_config(NULL, 'statsruntimedays')) {
set_config('statsruntimedays', '31');
}
}

return $result;
}

Expand Down
2 changes: 1 addition & 1 deletion version.php
Expand Up @@ -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 = 2007101526; // YYYYMMDD = date of the 1.9 branch (don't change)
$version = 2007101527; // YYYYMMDD = date of the 1.9 branch (don't change)
// X = release number 1.9.[0,1,2,3...]
// Y.YY = micro-increments between releases

Expand Down

0 comments on commit a1fb046

Please sign in to comment.