refacto labourage form

This commit is contained in:
Tykayn 2025-06-18 00:41:24 +02:00 committed by tykayn
parent 31b2bd4689
commit 5441abd405
12 changed files with 674 additions and 424 deletions

View file

@ -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
{