From ce7bbcbbbee77d37e9e08c175d619c470c32a4f7 Mon Sep 17 00:00:00 2001 From: Vasil Kolev Date: Fri, 20 Oct 2017 01:28:13 +0300 Subject: [PATCH] don't take slots from other rooms that have nothing to do with us --- schedule/parse.php | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/schedule/parse.php b/schedule/parse.php index 4146a21..c43fdfd 100644 --- a/schedule/parse.php +++ b/schedule/parse.php @@ -23,7 +23,13 @@ function parseData($config, $data) { // Collect the slots for each hall, sort them in order of starting $slots = []; $timestamps = []; - + + $filtered_type_id = + array_key_exists('filterEventType', $config) && + array_key_exists($config['filterEventType'], $config['eventTypes']) ? + $config['eventTypes'][$config['filterEventType']] : + null; + foreach ($data['halls'] as $hall_id => $hall) { $slots[$hall_id] = []; @@ -31,6 +37,12 @@ function parseData($config, $data) { if ($slot['hall_id'] !== $hall_id) { continue; } + + $eid = $slot['event_id']; + $etype = $data['events'][$eid]['event_type_id']; + if ($etype !== $filtered_type_id) { + continue; + } if (!in_array($slot['starts_at'], $timestamps)) { $timestamps[] = $slot['starts_at']; @@ -42,8 +54,8 @@ function parseData($config, $data) { $slots[$hall_id][$slot['starts_at']] = $slot; } - ksort($slots[$hall_id]); + if (empty($slots[$hall_id])) unset($slots[$hall_id]); } sort($timestamps); @@ -71,11 +83,6 @@ function parseData($config, $data) { // Fill in the event ID for each time slot in each hall $events = []; - $filtered_type_id = - array_key_exists('filterEventType', $config) && - array_key_exists($config['filterEventType'], $config['eventTypes']) ? - $config['eventTypes'][$config['filterEventType']] : - null; foreach ($data['halls'] as $hall_id => $hall) { $hall_data = [];