diff options
author | msquare <msquare@notrademark.de> | 2016-12-26 14:26:49 +0100 |
---|---|---|
committer | msquare <msquare@notrademark.de> | 2016-12-26 14:26:49 +0100 |
commit | deb41c4b64a59301aceb63257388bb2707bc9a75 (patch) | |
tree | 11a9a463dbf206e91ae39efc0f2e059249541a7e /includes | |
parent | 99c7e8ce1a668f567afed2a40d994961b2da0578 (diff) |
reduce number of sql queries on shift calendar
Diffstat (limited to 'includes')
-rw-r--r-- | includes/model/NeededAngelTypes_model.php | 5 | ||||
-rw-r--r-- | includes/model/ShiftEntry_model.php | 2 | ||||
-rw-r--r-- | includes/mysqli_provider.php | 3 | ||||
-rw-r--r-- | includes/view/ShiftCalendarShiftRenderer.php | 2 |
4 files changed, 7 insertions, 5 deletions
diff --git a/includes/model/NeededAngelTypes_model.php b/includes/model/NeededAngelTypes_model.php index e04ef8b8..76796869 100644 --- a/includes/model/NeededAngelTypes_model.php +++ b/includes/model/NeededAngelTypes_model.php @@ -84,13 +84,12 @@ function NeededAngelTypes_by_shift($shiftId) { } } + $shift_entries = ShiftEntries_by_shift($shiftId); $needed_angeltypes = []; foreach ($needed_angeltypes_source as $angeltype) { - $shift_entries = ShiftEntries_by_shift_and_angeltype($shiftId, $angeltype['angel_type_id']); - $angeltype['taken'] = 0; foreach($shift_entries as $shift_entry) { - if($shift_entry['freeloaded'] == 0) { + if($shift_entry['TID']==$angeltype['id'] && $shift_entry['freeloaded'] == 0) { $angeltype['taken']++; } } diff --git a/includes/model/ShiftEntry_model.php b/includes/model/ShiftEntry_model.php index dca7e1c1..9f4faf9e 100644 --- a/includes/model/ShiftEntry_model.php +++ b/includes/model/ShiftEntry_model.php @@ -28,7 +28,7 @@ function ShiftEntries_freeleaded_count() { */ function ShiftEntries_by_shift($shift_id) { return sql_select(" - SELECT `User`.`Nick`, `User`.`email`, `User`.`email_shiftinfo`, `User`.`Sprache`, `ShiftEntry`.`UID`, `ShiftEntry`.`TID`, `ShiftEntry`.`SID`, `AngelTypes`.`name` as `angel_type_name`, `ShiftEntry`.`Comment`, `ShiftEntry`.`freeloaded` + SELECT `User`.`Nick`, `User`.`email`, `User`.`email_shiftinfo`, `User`.`Sprache`, `User`.`Gekommen`, `ShiftEntry`.`UID`, `ShiftEntry`.`TID`, `ShiftEntry`.`SID`, `AngelTypes`.`name` as `angel_type_name`, `ShiftEntry`.`Comment`, `ShiftEntry`.`freeloaded` FROM `ShiftEntry` JOIN `User` ON `ShiftEntry`.`UID`=`User`.`UID` JOIN `AngelTypes` ON `ShiftEntry`.`TID`=`AngelTypes`.`id` diff --git a/includes/mysqli_provider.php b/includes/mysqli_provider.php index af05ca41..b1fd5f4a 100644 --- a/includes/mysqli_provider.php +++ b/includes/mysqli_provider.php @@ -131,6 +131,9 @@ function sql_select_db($db_name) { function sql_select($query) { global $sql_connection; + echo $query . ";\n"; + echo debug_string_backtrace() . "\n"; + $result = $sql_connection->query($query); if ($result) { $data = []; diff --git a/includes/view/ShiftCalendarShiftRenderer.php b/includes/view/ShiftCalendarShiftRenderer.php index 294a5936..50b1bf1b 100644 --- a/includes/view/ShiftCalendarShiftRenderer.php +++ b/includes/view/ShiftCalendarShiftRenderer.php @@ -107,7 +107,7 @@ class ShiftCalendarShiftRenderer { $entry_list = []; foreach ($angeltype['shift_entries'] as $entry) { $style = $entry['freeloaded'] ? " text-decoration: line-through;" : ''; - $entry_list[] = "<span style=\"$style\">" . User_Nick_render(User($entry['UID'])) . "</span>"; + $entry_list[] = "<span style=\"$style\">" . User_Nick_render($entry) . "</span>"; } $shift_signup_state = Shift_signup_allowed($user, $shift, $angeltype); $inner_text = sprintf(ngettext("%d helper needed", "%d helpers needed", $shift_signup_state->getFreeEntries()), $shift_signup_state->getFreeEntries()); |