refacto labourage form
This commit is contained in:
parent
31b2bd4689
commit
5441abd405
12 changed files with 674 additions and 424 deletions
|
@ -39,7 +39,7 @@ final class AdminController extends AbstractController
|
|||
|
||||
// Récupérer les stats existantes pour la zone
|
||||
$stats = $this->entityManager->getRepository(Stats::class)->findOneBy(['zone' => $insee_code]);
|
||||
|
||||
$urls = $stats->getAllCTCUrlsMap();
|
||||
|
||||
$statsHistory = $this->entityManager->getRepository(StatsHistory::class)
|
||||
->createQueryBuilder('sh')
|
||||
|
@ -90,6 +90,7 @@ final class AdminController extends AbstractController
|
|||
'maptiler_token' => $_ENV['MAPTILER_TOKEN'],
|
||||
'mapbox_token' => $_ENV['MAPBOX_TOKEN'],
|
||||
'statsHistory' => $statsHistory,
|
||||
'CTC_urls' => $urls,
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
@ -86,6 +86,87 @@ class Stats
|
|||
#[ORM\Column(nullable: true)]
|
||||
private ?int $avec_name = null;
|
||||
|
||||
public function getCTCurlBase(): ?string
|
||||
{
|
||||
$base = 'https://complete-tes-commerces.fr/';
|
||||
$zone = $this->zone;
|
||||
|
||||
$departement = substr($zone, 0, 2);
|
||||
$insee_code = $zone;
|
||||
$slug = strtolower(str_replace(' ', '-', $this->getName()));
|
||||
$url = $base . $departement . '/' . $insee_code . '-'.$slug.'/json/' . $slug ;
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
public function getLastStats(): string
|
||||
{
|
||||
return $this->getParametricJsonFromCTC('_last_stats');
|
||||
}
|
||||
|
||||
public function getDailyStats(): string
|
||||
{
|
||||
return $this->getParametricJsonFromCTC('_dailystats');
|
||||
}
|
||||
|
||||
public function getOSMClosedSirets(): string
|
||||
{
|
||||
return $this->getParametricJsonFromCTC('_osm_closed_siret');
|
||||
}
|
||||
|
||||
public function getOSMDisusedShops(): string
|
||||
{
|
||||
return $this->getParametricJsonFromCTC('_osm_disused_shops');
|
||||
}
|
||||
|
||||
public function getOSMNoSiteShops(): string
|
||||
{
|
||||
return $this->getParametricJsonFromCTC('_osm_no_site_shops');
|
||||
}
|
||||
|
||||
public function getPanoFile(): string
|
||||
{
|
||||
return $this->getParametricJsonFromCTC('_pano_file');
|
||||
}
|
||||
|
||||
public function getClosedPanoFile(): string
|
||||
{
|
||||
return $this->getParametricJsonFromCTC('_closed_pano_file');
|
||||
}
|
||||
|
||||
public function getSireneMatches(): string
|
||||
{
|
||||
return $this->getParametricJsonFromCTC('_sirene_matches');
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getParametricJsonFromCTC($suffixe): string
|
||||
{
|
||||
$url = $this->getCTCurlBase().$suffixe.'.json';
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
|
||||
public function getAllCTCUrlsMap(): ?array
|
||||
{
|
||||
$functions = [
|
||||
'getLastStats',
|
||||
'getDailyStats',
|
||||
'getOSMClosedSirets',
|
||||
'getOSMDisusedShops',
|
||||
'getOSMNoSiteShops',
|
||||
];
|
||||
|
||||
$urls = [];
|
||||
foreach ($functions as $function) {
|
||||
$urls[$function] = $this->$function();
|
||||
}
|
||||
return $urls;
|
||||
}
|
||||
|
||||
|
||||
// calcule le pourcentage de complétion de la zone
|
||||
public function computeCompletionPercent(): ?int
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue