mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
statistics MDL-25822 multiple values in get_field_sql
A variety of get_field_sql calls returning multiple values, switched to using MIN/MAX selects.
This commit is contained in:
parent
c63ebd4311
commit
5b903967de
@ -27,9 +27,9 @@
|
||||
|
||||
$reportoptions = stats_get_report_options($course->id,STATS_MODE_RANKED);
|
||||
|
||||
$earliestday = $DB->get_field_sql('SELECT timeend FROM {stats_daily} ORDER BY timeend');
|
||||
$earliestweek = $DB->get_field_sql('SELECT timeend FROM {stats_weekly} ORDER BY timeend');
|
||||
$earliestmonth = $DB->get_field_sql('SELECT timeend FROM {stats_monthly} ORDER BY timeend');
|
||||
$earliestday = $DB->get_field_sql('SELECT MIN(timeend) FROM {stats_daily}');
|
||||
$earliestweek = $DB->get_field_sql('SELECT MIN(timeend) FROM {stats_weekly}');
|
||||
$earliestmonth = $DB->get_field_sql('SELECT MIN(timeend) FROM {stats_monthly}');
|
||||
|
||||
if (empty($earliestday)) $earliestday = time();
|
||||
if (empty($earliestweek)) $earliestweek = time();
|
||||
|
@ -54,13 +54,13 @@ function report_stats_timeoptions($mode) {
|
||||
global $CFG, $DB;
|
||||
|
||||
if ($mode == STATS_MODE_DETAILED) {
|
||||
$earliestday = $DB->get_field_sql('SELECT timeend FROM {stats_user_daily} ORDER BY timeend');
|
||||
$earliestweek = $DB->get_field_sql('SELECT timeend FROM {stats_user_weekly} ORDER BY timeend');
|
||||
$earliestmonth = $DB->get_field_sql('SELECT timeend FROM {stats_user_monthly} ORDER BY timeend');
|
||||
$earliestday = $DB->get_field_sql('SELECT MIN(timeend) FROM {stats_user_daily}');
|
||||
$earliestweek = $DB->get_field_sql('SELECT MIN(timeend) FROM {stats_user_weekly}');
|
||||
$earliestmonth = $DB->get_field_sql('SELECT MIN(timeend) FROM {stats_user_monthly}');
|
||||
} else {
|
||||
$earliestday = $DB->get_field_sql('SELECT timeend FROM {stats_daily} ORDER BY timeend');
|
||||
$earliestweek = $DB->get_field_sql('SELECT timeend FROM {stats_weekly} ORDER BY timeend');
|
||||
$earliestmonth = $DB->get_field_sql('SELECT timeend FROM {stats_monthly} ORDER BY timeend');
|
||||
$earliestday = $DB->get_field_sql('SELECT MIN(timeend) FROM {stats_daily}');
|
||||
$earliestweek = $DB->get_field_sql('SELECT MIN(timeend) FROM {stats_weekly}');
|
||||
$earliestmonth = $DB->get_field_sql('SELECT MIN(timeend) FROM {stats_monthly}');
|
||||
}
|
||||
|
||||
|
||||
@ -90,4 +90,4 @@ function stats_report_extend_navigation($navigation, $course, $context) {
|
||||
$navigation->add(get_string('stats'), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/report', ''));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -854,13 +854,13 @@ function stats_get_start_from($str) {
|
||||
global $CFG, $DB;
|
||||
|
||||
// are there any data in stats table? Should not be...
|
||||
if ($timeend = $DB->get_field_sql('SELECT timeend FROM {stats_'.$str.'} ORDER BY timeend DESC')) {
|
||||
if ($timeend = $DB->get_field_sql('SELECT MAX(timeend) FROM {stats_'.$str.'}')) {
|
||||
return $timeend;
|
||||
}
|
||||
// decide what to do based on our config setting (either all or none or a timestamp)
|
||||
switch ($CFG->statsfirstrun) {
|
||||
case 'all':
|
||||
if ($firstlog = $DB->get_field_sql('SELECT time FROM {log} ORDER BY time ASC')) {
|
||||
if ($firstlog = $DB->get_field_sql('SELECT MIN(time) FROM {log}')) {
|
||||
return $firstlog;
|
||||
}
|
||||
default:
|
||||
|
Loading…
x
Reference in New Issue
Block a user