Skip to content

Commit d9b1ed4

Browse files
committed
Tracking: Fix queries in quarterly reports - refs BT#16108
1 parent df26e0a commit d9b1ed4

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

main/inc/lib/tracking.lib.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2596,16 +2596,16 @@ public static function getTotalTimeSpentInCourses(
25962596
if (api_is_multiple_url_enabled()) {
25972597
$accessUrlId = api_get_current_access_url_id();
25982598
$tableUrl = ", ".$tableUrlRelUser." as url_users";
2599-
$urlCondition = " AND u.login_user_id = url_users.user_id AND access_url_id = $accessUrlId";
2599+
$urlCondition = " AND teca.user_id = url_users.user_id AND url_users.access_url_id = $accessUrlId";
26002600
}
26012601

26022602
if (!empty($dateFrom) && !empty($dateUntil)) {
26032603
$dateFrom = Database::escape_string($dateFrom);
26042604
$dateUntil = Database::escape_string($dateUntil);
2605-
$conditionTime = " (login_course_date >= '$dateFrom' AND logout_course_date <= '$dateUntil' ) ";
2605+
$conditionTime = " (teca.login_course_date >= '$dateFrom' AND teca.logout_course_date <= '$dateUntil' ) ";
26062606
}
2607-
$sql = "SELECT SUM(TIMESTAMPDIFF(HOUR, login_course_date, logout_course_date)) diff
2608-
FROM $tableTrackLogin u $tableUrl
2607+
$sql = "SELECT SUM(TIMESTAMPDIFF(HOUR, teca.login_course_date, teca.logout_course_date)) diff
2608+
FROM $tableTrackLogin teca $tableUrl
26092609
WHERE $conditionTime $urlCondition";
26102610

26112611
$rs = Database::query($sql);

main/inc/lib/usermanager.lib.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4563,15 +4563,19 @@ public static function is_admin($user_id)
45634563
* @return mixed Number of users or false on error
45644564
*/
45654565
public static function get_number_of_users(
4566-
$status = 0,
4567-
$access_url_id = 1,
4568-
$active = null,
4566+
int $status = null,
4567+
int $access_url_id = null,
4568+
int $active = null,
45694569
string $dateFrom = null,
45704570
string $dateUntil = null
45714571
) {
45724572
$tableUser = Database::get_main_table(TABLE_MAIN_USER);
45734573
$tableAccessUrlRelUser = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
45744574

4575+
if (empty($access_url_id)) {
4576+
$access_url_id = api_get_current_access_url_id();
4577+
}
4578+
45754579
if (api_is_multiple_url_enabled()) {
45764580
$sql = "SELECT count(u.id)
45774581
FROM $tableUser u

0 commit comments

Comments
 (0)