From 20f4d44cbf159f25f78312290be52fcfafef02de Mon Sep 17 00:00:00 2001 From: msquare Date: Thu, 14 Dec 2017 19:39:47 +0100 Subject: fix union queries for dashboard stats --- includes/model/Shifts_model.php | 2 ++ includes/model/Stats.php | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'includes') diff --git a/includes/model/Shifts_model.php b/includes/model/Shifts_model.php index 2a77fd35..8cbbe2aa 100644 --- a/includes/model/Shifts_model.php +++ b/includes/model/Shifts_model.php @@ -38,6 +38,7 @@ function Shifts_free($start, $end) WHERE (`end` > ? AND `start` < ?) AND (SELECT SUM(`count`) FROM `NeededAngelTypes` WHERE `NeededAngelTypes`.`shift_id`=`Shifts`.`SID`) > (SELECT COUNT(*) FROM `ShiftEntry` WHERE `ShiftEntry`.`SID`=`Shifts`.`SID` AND `freeloaded`=0) + AND `Shifts`.`PSID` IS NULL UNION @@ -46,6 +47,7 @@ function Shifts_free($start, $end) WHERE (`end` > ? AND `start` < ?) AND (SELECT SUM(`count`) FROM `NeededAngelTypes` WHERE `NeededAngelTypes`.`room_id`=`Shifts`.`RID`) > (SELECT COUNT(*) FROM `ShiftEntry` WHERE `ShiftEntry`.`SID`=`Shifts`.`SID` AND `freeloaded`=0) + AND NOT `Shifts`.`PSID` IS NULL ) as `tmp` ORDER BY `tmp`.`start` ", [ diff --git a/includes/model/Stats.php b/includes/model/Stats.php index 5bca0aff..0c581fa9 100644 --- a/includes/model/Stats.php +++ b/includes/model/Stats.php @@ -35,7 +35,7 @@ function stats_hours_to_work() WHERE `end` >= ? AND `Shifts`.`PSID` IS NULL - UNION + UNION ALL SELECT (SELECT SUM(`count`) FROM `NeededAngelTypes` WHERE `NeededAngelTypes`.`room_id`=`Shifts`.`RID`) @@ -71,7 +71,7 @@ function stats_angels_needed_three_hours() WHERE `end` > ? AND `start` < ? AND `Shifts`.`PSID` IS NULL - UNION + UNION ALL SELECT (SELECT SUM(`count`) FROM `NeededAngelTypes` WHERE `NeededAngelTypes`.`room_id`=`Shifts`.`RID`) @@ -109,7 +109,7 @@ function stats_angels_needed_for_nightshifts() WHERE `end` > ? AND `start` < ? AND `Shifts`.`PSID` IS NULL - UNION + UNION ALL SELECT (SELECT SUM(`count`) FROM `NeededAngelTypes` WHERE `NeededAngelTypes`.`room_id`=`Shifts`.`RID`) -- cgit v1.2.3-70-g09d2