Commit c890bb69 authored by Andrea Ruggiero's avatar Andrea Ruggiero
Browse files

fix

parent bcacca29
Pipeline #1568 failed with stage
in 0 seconds
......@@ -87,8 +87,38 @@ class EventController extends Controller
$user = $sessionRepository->getUserByToken($request->headers->get('X-Auth-Token'));
$skip = [];
foreach ($events as $event) {
if ($bookingRepository->getBookingByEventAndUser($user->user_id, $event->event_id) === null) continue;
if (isset($skip[$event->event_id])) continue;
$places = [];
foreach ($eventRepository->getSimilarEvents($event) as $e) {
$skip[$e["event_id"]] = false;
if ($event->place_id === null) {
$places = array_map(function($place) {
return [
"place" => $place->name,
"capacity" => $place->capacity,
"latitude" => $place->latitude,
"longitude" => $place->longitude,
"address" => $place->address
];
}, $placeRepository->all());
break;
} else {
$place = $placeRepository->getById($e["place_id"]);
$places[] = [
"place" => $place->name,
"capacity" => $place->capacity,
"latitude" => $place->latitude,
"longitude" => $place->longitude,
"address" => $place->address
];
}
}
$temp = [
"id" => $event->event_id,
"title" => $event->title,
......@@ -99,7 +129,7 @@ class EventController extends Controller
"type" => $event->type,
"theme" => $event->theme,
"bookings" => count($bookingRepository->getBookingsByEvent($event->event_id)),
"places" => $eventRepository->getPlaces($event, $placeRepository)
"places" => $places
];
$response[] = $temp;
......@@ -146,6 +176,31 @@ class EventController extends Controller
$user = $sessionRepository->getUserByToken($request->headers->get('X-Auth-Token'));
$places = [];
foreach ($eventRepository->getSimilarEvents($event) as $e) {
if ($event->place_id === null) {
$places = array_map(function($place) {
return [
"place" => $place->name,
"capacity" => $place->capacity,
"latitude" => $place->latitude,
"longitude" => $place->longitude,
"address" => $place->address
];
}, $placeRepository->all());
break;
} else {
$place = $placeRepository->getById($e["place_id"]);
$places[] = [
"place" => $place->name,
"capacity" => $place->capacity,
"latitude" => $place->latitude,
"longitude" => $place->longitude,
"address" => $place->address
];
}
}
$response = [
"id" => $event->event_id,
"title" => $event->title,
......@@ -156,7 +211,7 @@ class EventController extends Controller
"type" => $event->type,
"theme" => $event->theme,
"bookings" => count($bookingRepository->getBookingsByEvent($event->event_id)),
"places" => $eventRepository->getPlaces($event, $placeRepository)
"places" => $places
];
if ($user !== null) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment