]> git.mjollnir.org Git - moodle.git/commitdiff
Adding new setting "statsruntimedays" to configure the number of days to
authorstronk7 <stronk7>
Mon, 13 Oct 2008 21:53:49 +0000 (21:53 +0000)
committerstronk7 <stronk7>
Mon, 13 Oct 2008 21:53:49 +0000 (21:53 +0000)
calculate as max per stats cron invocation. Part of MDL-16709 ; merged from 19_STABLE

admin/cron.php
admin/settings/server.php
lang/en_utf8/admin.php
lib/db/upgrade.php
version.php

index c90d28b57cf9cc077a0f0b29f9214e8f451eed0d..784f3022ce2ea728d9ce12014aeecf7e2e0be6d7 100644 (file)
         $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();
index 296eb87558497650c6de559ce7f35632852bc89f..7fdb9f5c521080dd5901eac934b29e66fc49d8f9 100644 (file)
@@ -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));
 
index 7d7ed1814cd177769364eba28927367855159737..07d1e9901c959c07978472d7af5fc4edbc3ebbfc 100644 (file)
@@ -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 <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.';
@@ -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';
index b79ad6d58acb5e057ec579e5f97016578eb3aacd..862e8e5a73d8bc17fd59ec5ef40f94fd4c9eee98 100644 (file)
@@ -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;
 }
index dfd1dd043adad7619f452e5f9ebe8c623c86d470..d5968508461866b81310f3636a7a1d25b8473f40 100644 (file)
@@ -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