Merge branch 'MDL-68052' of git://github.com/danmarsden/moodle

This commit is contained in:
Adrian Greeve 2020-11-30 09:39:51 +08:00
commit bc581748c2
3 changed files with 25 additions and 0 deletions

View File

@ -144,5 +144,20 @@ if ($hassiteconfig && \core_analytics\manager::is_analytics_enabled()) {
$settings->add(new admin_setting_configduration('analytics/modeltimelimit', new lang_string('modeltimelimit', 'analytics'),
new lang_string('modeltimelimitinfo', 'analytics'), 20 * MINSECS));
$options = array(
0 => new lang_string('neverdelete', 'analytics'),
1000 => new lang_string('numdays', '', 1000),
365 => new lang_string('numdays', '', 365),
180 => new lang_string('numdays', '', 180),
150 => new lang_string('numdays', '', 150),
120 => new lang_string('numdays', '', 120),
90 => new lang_string('numdays', '', 90),
60 => new lang_string('numdays', '', 60),
35 => new lang_string('numdays', '', 35));
$settings->add(new admin_setting_configselect('analytics/calclifetime',
new lang_string('calclifetime', 'analytics'),
new lang_string('configlcalclifetime', 'analytics'), 35, $options));
}
}

View File

@ -694,6 +694,13 @@ class manager {
$param + $idsparams);
}
}
// Clean up calculations table.
$calclifetime = get_config('analytics', 'calclifetime');
if (!empty($calclifetime)) {
$lifetime = time() - ($calclifetime * DAYSECS); // Value in days.
$DB->delete_records_select('analytics_indicator_calc', 'timecreated < ?', [$lifetime]);
}
}
/**

View File

@ -31,6 +31,8 @@ $string['analyticslogstore'] = 'Log store used for analytics';
$string['analyticslogstore_help'] = 'The log store that will be used by the analytics API to read users\' activity.';
$string['analyticssettings'] = 'Analytics settings';
$string['analyticssiteinfo'] = 'Site information';
$string['calclifetime'] = 'Keep analytics calculations for';
$string['configlcalclifetime'] = 'This specifies the length of time you want to keep calculation data - this will not delete predictions, but deletes the data used to generate the predictions. Using the default option here is best as it keeps your disk usage under control, however if you are using calculation tables for other purposes you may want to increase this value.';
$string['defaulttimesplittingmethods'] = 'Default analysis intervals for model\'s evaluation';
$string['defaulttimesplittingmethods_help'] = 'The analysis interval defines when the system will calculate predictions and the portion of activity logs that will be considered for those predictions. The model evaluation process will iterate through these analysis intervals unless a specific analysis interval is specified.';
$string['defaultpredictionsprocessor'] = 'Default predictions processor';
@ -97,6 +99,7 @@ $string['modeloutputdirwithdefaultinfo'] = 'Directory where prediction processor
$string['modeltimelimit'] = 'Analysis time limit per model';
$string['modeltimelimitinfo'] = 'This setting limits the time each model spends analysing the site contents.';
$string['neutral'] = 'Neutral';
$string['neverdelete'] = 'Never delete calculations';
$string['noevaluationbasedassumptions'] = 'Models based on assumptions cannot be evaluated.';
$string['nodata'] = 'No data to analyse';
$string['noinsightsmodel'] = 'This model does not generate insights';