From 087be6ca90a8d423c8f9eb14de9eb54d1a820c23 Mon Sep 17 00:00:00 2001 From: Andrea Bicciolo Date: Wed, 29 Oct 2014 12:44:16 +0800 Subject: [PATCH] MDL-47201 Reports: Read from multiple log stores in outline report --- report/outline/index.php | 7 ++++++- report/outline/locallib.php | 2 -- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/report/outline/index.php b/report/outline/index.php index dd5d0e09373..b9ea023cf20 100644 --- a/report/outline/index.php +++ b/report/outline/index.php @@ -110,7 +110,6 @@ if ($uselegacyreader) { $limittime = ''; if (!empty($minloginternalreader)) { $limittime = ' AND time < :timeto '; - $params['timeto'] = $minloginternalreader; } // Check if we need to show the last access. $sqllasttime = ''; @@ -129,6 +128,9 @@ if ($uselegacyreader) { AND m.visible = :visible $limittime GROUP BY cm.id"; $params = array('courseid' => $course->id, 'action' => 'view%', 'visible' => 1); + if (!empty($minloginternalreader)) { + $params['timeto'] = $minloginternalreader; + } $views = $DB->get_records_sql($sql, $params); } @@ -156,6 +158,9 @@ if ($useinternalreader) { foreach ($v as $key => $value) { if (isset($views[$key]) && !empty($views[$key]->numviews)) { $views[$key]->numviews += $value->numviews; + if ($value->lasttime > $views[$key]->lasttime) { + $views[$key]->lasttime = $value->lasttime; + } } else { $views[$key] = $value; } diff --git a/report/outline/locallib.php b/report/outline/locallib.php index e301bec34ae..600cb3e9d0b 100644 --- a/report/outline/locallib.php +++ b/report/outline/locallib.php @@ -85,7 +85,6 @@ function report_outline_get_common_log_variables() { // If legacy reader is preferred reader. if ($readerpluginname == 'logstore_legacy') { $uselegacyreader = true; - break; } // If sql_internal_reader is preferred reader. @@ -93,7 +92,6 @@ function report_outline_get_common_log_variables() { $useinternalreader = true; $logtable = $reader->get_internal_log_table_name(); $minloginternalreader = $DB->get_field_sql('SELECT min(timecreated) FROM {' . $logtable . '}'); - break; } } }