don't take slots from other rooms that have nothing to do with us

This commit is contained in:
Vasil Kolev 2017-10-20 01:28:13 +03:00 committed by Openfest
parent 3e5047028f
commit ce7bbcbbbe
1 changed files with 14 additions and 7 deletions

View File

@ -23,7 +23,13 @@ function parseData($config, $data) {
// Collect the slots for each hall, sort them in order of starting // Collect the slots for each hall, sort them in order of starting
$slots = []; $slots = [];
$timestamps = []; $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) { foreach ($data['halls'] as $hall_id => $hall) {
$slots[$hall_id] = []; $slots[$hall_id] = [];
@ -31,6 +37,12 @@ function parseData($config, $data) {
if ($slot['hall_id'] !== $hall_id) { if ($slot['hall_id'] !== $hall_id) {
continue; 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)) { if (!in_array($slot['starts_at'], $timestamps)) {
$timestamps[] = $slot['starts_at']; $timestamps[] = $slot['starts_at'];
@ -42,8 +54,8 @@ function parseData($config, $data) {
$slots[$hall_id][$slot['starts_at']] = $slot; $slots[$hall_id][$slot['starts_at']] = $slot;
} }
ksort($slots[$hall_id]); ksort($slots[$hall_id]);
if (empty($slots[$hall_id])) unset($slots[$hall_id]);
} }
sort($timestamps); sort($timestamps);
@ -71,11 +83,6 @@ function parseData($config, $data) {
// Fill in the event ID for each time slot in each hall // Fill in the event ID for each time slot in each hall
$events = []; $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) { foreach ($data['halls'] as $hall_id => $hall) {
$hall_data = []; $hall_data = [];