src/Aqarmap/Bundle/NeighborhoodBundle/Controller/Api/NeighborhoodController.php line 195
/** @var $em \Doctrine\ORM\EntityManager */
$em = $this->managerRegistry->getManager();
$sections = json_decode($request->request->get('data'), 1);
$em->getConnection()->getConfiguration()->setSQLLogger(null);
gc_collect_cycles();
set_time_limit(0);
$errors = [];
$this->logger->debug('entered');
if (is_array($sections) || is_object($sections)) {
foreach ($sections as $sectionId => $section) {
$this->logger->debug('entered loop');
foreach ($section as $propertyTypeId => $propertyType) {
foreach ($propertyType as $locationId => $data) {
try {
$this->messageBus->dispatch(new LocationStatisticsMessage(
(int) $locationId,
(int) $sectionId,
(int) $propertyTypeId,
$data,
));
$this->logger->error('modular 0 ');
} catch (\Exception $e) {
$errors[] = $e->getMessage();
}
}
}
}
if (!empty($errors)) {
$this->logger->error('valuationerrors', $errors);
return $this->respond(['errors' => $errors], Response::HTTP_INTERNAL_SERVER_ERROR);
}
}
return $this->respond(true);
}
/**
* Get Neighborhood First Level Locations Without Children.
*
* **Response Format**
*
* ```
* {
* "location":
* {
* "id": 1,
* "title": "Cairo",
* "description": "Cairo City",
* "center_lat": 30.04841,
* "center_lng": 31.23619,
* "zoom_level": 10,
* "searchable": true,
* "home_filter": true,
* "statistics_filter": true,
* "neighborhood_filter": true,
* }
* {...
* }
* ]
* },
* {...
* }
* }
* ```
*
* @return array
*/
#[Rest\Get('/api/v2/neighborhood', options: ['i18n' => false], name: 'aqarmap_api_neighborhood_location')]
#[Rest\View(serializerGroups: ['Default', 'Neighborhood'])]
public function getNeighborhoodLocation()
{
/** @var $em \Doctrine\ORM\EntityManager */
$em = $this->managerRegistry->getManager();
$locations = $em->getRepository(Location::class)->getNeighbourhoodLocations(['level' => 0]);
return [
'locations' => $locations,
];
}
/**
* Get Neighborhood Location With Children.
*
* @return array
*/
#[Rest\Get('/api/v2/neighborhood/{location}', options: ['i18n' => false], name: 'aqarmap_api_neighborhood_location_details')]
#[Rest\View(serializerGroups: ['Default', 'Neighborhood'])]
public function getNeighborhoodDetails(Location $location)
{
return [
'location' => $location,
'children' => $location->getNeighborhoodChildren(),
];
}
/**
* Get Neighborhood History For Crm App.
*
* @return array
*/
#[Rest\Get('/api/v2/neighborhood/{location}/history', options: ['i18n' => false], name: 'aqarmap_api_neighborhood_history_data')]
#[Rest\View(serializerGroups: ['Default', 'NeighborhoodStatistics'])]
public function getNeighborhoodHistory(Location $location)
{
$historyData = $this->neighborhoodManager->generateStatisticsHistoryData($location);
foreach ($historyData['historyData'] as &$value) {
$value['data']['average_price'] = array_values($value['data']['average_price']);
$value['data']['demand_heat'] = array_values($value['data']['demand_heat']);
$value['data']['growth'] = array_values($value['data']['growth']);
}
return [
'location' => $location,
'data' => $historyData['historyData'],
];
}
}