motocultrice labourer aussi les lieux sans email, et proposition opening hours
This commit is contained in:
parent
268ac799e4
commit
cae369c9cd
9 changed files with 565 additions and 53 deletions
|
@ -94,7 +94,7 @@ final class AdminController extends AbstractController
|
|||
// Redirection vers la page de modification avec les paramètres nécessaires
|
||||
return $this->redirectToRoute('app_public_edit', [
|
||||
'zipcode' => $commerce->getZipCode(),
|
||||
'name' => $commerce->getName() ?? '?',
|
||||
'name' => $commerce->getName()!='' ? $commerce->getName() : '?',
|
||||
'uuid' => $commerce->getUuidForUrl()
|
||||
]);
|
||||
}
|
||||
|
@ -130,6 +130,9 @@ final class AdminController extends AbstractController
|
|||
$this->entityManager->flush();
|
||||
}
|
||||
|
||||
$commerces = $this->entityManager->getRepository(Place::class)->findBy(['zip_code' => $zip_code]);
|
||||
|
||||
|
||||
// Initialiser les compteurs
|
||||
$counters = [
|
||||
'avec_horaires' => 0,
|
||||
|
@ -213,6 +216,9 @@ final class AdminController extends AbstractController
|
|||
|
||||
$this->entityManager->flush();
|
||||
|
||||
$commerces = $this->entityManager->getRepository(Place::class)->findBy(['zip_code' => $zip_code]);
|
||||
|
||||
// var_dump($commerces[0]);
|
||||
return $this->render('admin/labourage_results.html.twig', [
|
||||
'results' => $results,
|
||||
'commerces' => $commerces,
|
||||
|
|
|
@ -377,4 +377,14 @@ class PublicController extends AbstractController
|
|||
'closed_places' => $closedPlaces
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/places_with_note', name: 'app_public_places_with_note')]
|
||||
public function places_with_note(): Response
|
||||
{
|
||||
$places = $this->entityManager->getRepository(Place::class)->findBy(['note' => '']);
|
||||
return $this->render('public/places_with_note.html.twig', [
|
||||
'controller_name' => 'PublicController',
|
||||
'places' => $places
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -111,6 +111,9 @@ class Motocultrice
|
|||
|
||||
public function labourer(string $zone): array
|
||||
{
|
||||
|
||||
$use_places_without_email_to_reference = $_ENV['USE_PLACES_WITHOUT_EMAIL_TO_REFERENCE'] ?? false;
|
||||
|
||||
if (!$zone) {
|
||||
throw new \InvalidArgumentException("La zone ne peut pas être vide");
|
||||
}
|
||||
|
@ -119,27 +122,44 @@ class Motocultrice
|
|||
$zone = addslashes(trim($zone));
|
||||
|
||||
$query = <<<QUERY
|
||||
[out:json][timeout:25];
|
||||
area["postal_code"="{$zone}"]->.searchArea;
|
||||
(
|
||||
// Recherche des commerces et services avec email
|
||||
nw["amenity"]["contact:email"](area.searchArea);
|
||||
nw["amenity"]["email"](area.searchArea);
|
||||
nw["shop"]["contact:email"](area.searchArea);
|
||||
nw["shop"]["email"](area.searchArea);
|
||||
nw["office"]["contact:email"](area.searchArea);
|
||||
nw["office"]["email"](area.searchArea);
|
||||
|
||||
// Recherche des commerces et services sans email pour référence
|
||||
nw["amenity"](area.searchArea);
|
||||
nw["shop"](area.searchArea);
|
||||
nw["office"](area.searchArea);
|
||||
);
|
||||
out body;
|
||||
>;
|
||||
out skel qt;
|
||||
[out:json][timeout:25];
|
||||
area["postal_code"="{$zone}"]->.searchArea;
|
||||
(
|
||||
// Recherche des commerces et services avec email
|
||||
nw["amenity"]["contact:email"](area.searchArea);
|
||||
nw["amenity"]["email"](area.searchArea);
|
||||
nw["shop"]["contact:email"](area.searchArea);
|
||||
nw["shop"]["email"](area.searchArea);
|
||||
nw["office"]["contact:email"](area.searchArea);
|
||||
nw["office"]["email"](area.searchArea);
|
||||
|
||||
// Recherche des commerces et services sans email pour référence
|
||||
nw["amenity"](area.searchArea);
|
||||
nw["shop"](area.searchArea);
|
||||
nw["office"](area.searchArea);
|
||||
);
|
||||
out body;
|
||||
>;
|
||||
out skel qt;
|
||||
QUERY;
|
||||
|
||||
if($use_places_without_email_to_reference) {
|
||||
$query = <<<QUERY
|
||||
|
||||
[out:json][timeout:25];
|
||||
area["postal_code"="{$zone}"]->.searchArea;
|
||||
(
|
||||
nw["amenity"]["cafe|bar|restaurant"](area.searchArea);
|
||||
nw["shop"](area.searchArea);
|
||||
nw["tourism"="museum"](area.searchArea);
|
||||
nw["office"](area.searchArea);
|
||||
);
|
||||
out body;
|
||||
>;
|
||||
out skel qt;
|
||||
QUERY;
|
||||
}
|
||||
|
||||
try {
|
||||
$response = $this->client->request('POST', $this->overpassApiUrl, [
|
||||
'body' => ['data' => $query]
|
||||
|
@ -152,13 +172,15 @@ QUERY;
|
|||
foreach ($data['elements'] as $element) {
|
||||
if (isset($element['tags'])) {
|
||||
|
||||
|
||||
$email = "";
|
||||
if( ! $use_places_without_email_to_reference){
|
||||
|
||||
$email = $element['tags']['contact:email'] ?? $element['tags']['email'] ?? null;
|
||||
// On passe si pas d'email
|
||||
if (!$email) {
|
||||
continue;
|
||||
}
|
||||
$email = $element['tags']['contact:email'] ?? $element['tags']['email'] ?? null;
|
||||
// On passe si pas d'email
|
||||
if (!$email) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$places[] = [
|
||||
'id' => $element['id'],
|
||||
|
@ -175,6 +197,9 @@ QUERY;
|
|||
|
||||
return $places;
|
||||
} catch (\Exception $e) {
|
||||
var_dump($query);
|
||||
var_dump($e->getMessage());
|
||||
die();
|
||||
throw new \Exception("Erreur lors de la requête Overpass : " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
@ -202,9 +227,19 @@ QUERY;
|
|||
} elseif (isset($osm_object_data['way'])) {
|
||||
$osm_object_data['way']['tags_converted'] = [];
|
||||
}
|
||||
if(isset($osm_object_data['node'])){
|
||||
foreach ($osm_object_data['node']['tag'] as $attribute) {
|
||||
$osm_object_data['node']['tags_converted'][$attribute['@attributes']['k']] = $attribute['@attributes']['v'];
|
||||
if(isset($osm_object_data['node'])){
|
||||
// Vérifier si le nœud a des tags
|
||||
if (!isset($osm_object_data['node']['tag'])) {
|
||||
$osm_object_data['node']['tags_converted'] = [];
|
||||
return $osm_object_data['node'];
|
||||
}
|
||||
|
||||
// Si un seul tag, le convertir en tableau
|
||||
if (isset($osm_object_data['node']['tag']['@attributes'])) {
|
||||
$osm_object_data['node']['tag'] = [$osm_object_data['node']['tag']];
|
||||
}
|
||||
foreach ($osm_object_data['node']['tag'] as $tag) {
|
||||
$osm_object_data['node']['tags_converted'][$tag['@attributes']['k']] = $tag['@attributes']['v'];
|
||||
}
|
||||
$osm_object_data['node']['tags_converted'] = $this->migrate_tags($osm_object_data['node']['tags_converted']);
|
||||
return $osm_object_data['node'];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue