summaryrefslogtreecommitdiff
path: root/includes/view/ShiftCalendarRenderer.php
diff options
context:
space:
mode:
authormsquare <msquare@notrademark.de>2016-12-27 23:02:05 +0100
committermsquare <msquare@notrademark.de>2016-12-27 23:02:05 +0100
commit46528fe1d888ae09d125c2ae8ac1952f1d7f29f6 (patch)
treeb8361bb6aff1307845c9903d2693121835e8d033 /includes/view/ShiftCalendarRenderer.php
parentffc33993d4cea15d4d8a4af631afdd97c3567c36 (diff)
shift view performance improvements
Diffstat (limited to 'includes/view/ShiftCalendarRenderer.php')
-rw-r--r--includes/view/ShiftCalendarRenderer.php26
1 files changed, 24 insertions, 2 deletions
diff --git a/includes/view/ShiftCalendarRenderer.php b/includes/view/ShiftCalendarRenderer.php
index 7f39d64e..d8d31bd0 100644
--- a/includes/view/ShiftCalendarRenderer.php
+++ b/includes/view/ShiftCalendarRenderer.php
@@ -35,11 +35,17 @@ class ShiftCalendarRenderer {
private $blocksPerSlot = null;
- public function __construct($shifts, ShiftsFilter $shiftsFilter) {
+ private $needed_angeltypes = null;
+
+ private $shift_entries = null;
+
+ public function __construct($shifts, $needed_angeltypes, $shift_entries, ShiftsFilter $shiftsFilter) {
$this->shiftsFilter = $shiftsFilter;
$this->firstBlockStartTime = $this->calcFirstBlockStartTime($shifts);
$this->lastBlockEndTime = $this->calcLastBlockEndTime($shifts);
$this->lanes = $this->assignShiftsToLanes($shifts);
+ $this->needed_angeltypes = $needed_angeltypes;
+ $this->shift_entries = $shift_entries;
}
/**
@@ -127,6 +133,7 @@ class ShiftCalendarRenderer {
$html .= $this->renderLane($lane);
}
}
+
return $html;
}
@@ -142,16 +149,31 @@ class ShiftCalendarRenderer {
$shift_renderer = new ShiftCalendarShiftRenderer();
$html = "";
$rendered_until = $this->getFirstBlockStartTime();
+
+ $needed_angeltypes = [];
+ $shift_entries = [];
+ foreach ($lane->getShifts() as $shift) {
+ $needed_angeltypes[$shift['SID']] = [];
+ $shift_entries[$shift['SID']] = [];
+ }
+ foreach ($this->needed_angeltypes as $needed_angeltype) {
+ $needed_angeltypes[$needed_angeltype['shift_id']][] = $needed_angeltype;
+ }
+ foreach ($this->shift_entries as $shift_entry) {
+ $shift_entries[$shift_entry['SID']][] = $shift_entry;
+ }
+
foreach ($lane->getShifts() as $shift) {
while ($rendered_until + ShiftCalendarRenderer::SECONDS_PER_ROW <= $shift['start']) {
$html .= $this->renderTick($rendered_until);
$rendered_until += ShiftCalendarRenderer::SECONDS_PER_ROW;
}
- list($shift_height, $shift_html) = $shift_renderer->render($shift, $user);
+ list($shift_height, $shift_html) = $shift_renderer->render($shift, $needed_angeltypes[$shift['SID']], $shift_entries[$shift['SID']], $user);
$html .= $shift_html;
$rendered_until += $shift_height * ShiftCalendarRenderer::SECONDS_PER_ROW;
}
+
while ($rendered_until < $this->getLastBlockEndTime()) {
$html .= $this->renderTick($rendered_until);
$rendered_until += ShiftCalendarRenderer::SECONDS_PER_ROW;