summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorJan-Philipp Litza <janphilipp@litza.de>2012-12-30 13:59:07 +0100
committerJan-Philipp Litza <janphilipp@litza.de>2012-12-30 13:59:07 +0100
commit0d47caa09ba5837698f4974e1b291a297a8e935b (patch)
tree99afcae9d7ef24d8d11f771e813d3ff1431b343b /includes
parentf91e00adc78e1f1c3b0fdb59c7810f273bd1c709 (diff)
simplified stats generation
Diffstat (limited to 'includes')
-rw-r--r--includes/pages/guest_stats.php9
1 files changed, 3 insertions, 6 deletions
diff --git a/includes/pages/guest_stats.php b/includes/pages/guest_stats.php
index 80df246b..da5a6301 100644
--- a/includes/pages/guest_stats.php
+++ b/includes/pages/guest_stats.php
@@ -13,13 +13,10 @@ function guest_stats() {
list($arrived_user_count) = sql_select("SELECT count(*) as `user_count` FROM `User` WHERE `Gekommen`=1");
$stats['arrived_user_count'] = $arrived_user_count['user_count'];
- $done_shifts_source = sql_select("SELECT `Shifts`.`start`, `Shifts`.`end` FROM `ShiftEntry` JOIN `Shifts` ON `Shifts`.`SID`=`ShiftEntry`.`SID` WHERE `Shifts`.`end` < " . time());
- $done_shifts_seconds = 0;
- foreach($done_shifts_source as $done_shift)
- $done_shifts_seconds += $done_shift['end'] - $done_shift['start'];
+ $done_shifts_seconds = sql_select_single_cell("SELECT SUM(`Shifts`.`end` - `Shifts`.`start`) FROM `ShiftEntry` JOIN `Shifts` USING (`SID`) WHERE `Shifts`.`end` < UNIX_TIMESTAMP()");
$stats['done_work_hours'] = round($done_shifts_seconds / (60*60), 0);
- $users_in_action_source = sql_select("SELECT `Shifts`.`start`, `Shifts`.`end` FROM `ShiftEntry` JOIN `Shifts` ON `Shifts`.`SID`=`ShiftEntry`.`SID` WHERE `Shifts`.`start` < " . time() . " AND `Shifts`.`end` > " . time());
+ $users_in_action_source = sql_select("SELECT `Shifts`.`start`, `Shifts`.`end` FROM `ShiftEntry` JOIN `Shifts` ON `Shifts`.`SID`=`ShiftEntry`.`SID` WHERE UNIX_TIMESTAMP() BETWEEN `Shifts`.`start` AND `Shifts`.`end`");
$stats['users_in_action'] = count($users_in_action_source);
header("Content-Type: application/json");
@@ -30,4 +27,4 @@ function guest_stats() {
}
-?> \ No newline at end of file
+?>