From a1fb0461d1b312fc64eea5e77466e89164391e1e Mon Sep 17 00:00:00 2001 From: stronk7 Date: Mon, 13 Oct 2008 21:45:23 +0000 Subject: [PATCH] Adding new setting "statsruntimedays" to configure the number of days to calculate as max per stats cron invocation. Part of MDL-16709 --- admin/cron.php | 5 +++-- admin/settings/server.php | 3 ++- lang/en_utf8/admin.php | 5 ++++- lib/db/upgrade.php | 6 ++++++ version.php | 2 +- 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/admin/cron.php b/admin/cron.php index 5582537f07a37..22af9512cb853 100644 --- a/admin/cron.php +++ b/admin/cron.php @@ -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(); diff --git a/admin/settings/server.php b/admin/settings/server.php index 603094009cb33..d64c4cf31e3be 100644 --- a/admin/settings/server.php +++ b/admin/settings/server.php @@ -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'), @@ -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)); diff --git a/lang/en_utf8/admin.php b/lang/en_utf8/admin.php index 9d0ab8930dab9..13ff46afa904d 100644 --- a/lang/en_utf8/admin.php +++ b/lang/en_utf8/admin.php @@ -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 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.'; @@ -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'; diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index 87721397906c2..a75afa671bcea 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -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; } diff --git a/version.php b/version.php index fd14459289819..839cc7e2be1b4 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 = 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