Entrega dashboard e correccoes transversais preservando Ofertas instalado
tests / ci (push) Canceled after 0s
tests / ci (push) Canceled after 0s
This commit is contained in:
@@ -34,6 +34,29 @@ final class DemographicEvidence
|
||||
return ['commerce' => 'Comércio e serviços', 'industry' => 'Indústria', 'agriculture' => 'Agricultura e agro-indústria', 'education' => 'Educação', 'health' => 'Saúde', 'general' => 'Contexto geral'];
|
||||
}
|
||||
|
||||
/** Broader administrative evidence stays labelled as context, never local data.
|
||||
* @return array<string,mixed>
|
||||
*/
|
||||
public function investmentContext(string $territory, int $start, int $end, string $sector = 'general', ?string $edition = null): array
|
||||
{
|
||||
$path = app(InvestmentGeography::class)->path($territory);
|
||||
$requested = collect($path)->last();
|
||||
$result = $this->analyse([], $start, $end, $sector, $edition);
|
||||
foreach (array_reverse($path) as $node) {
|
||||
if (! in_array($node->location_type, ['district', 'province'], true)) {
|
||||
continue;
|
||||
}
|
||||
$result = $this->analyse([$node->id], $start, $end, $sector, $edition);
|
||||
if ($result['state'] === 'available') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
$result['requested_territory'] = $requested ? ['id' => $requested->id, 'name' => $requested->name, 'level' => $requested->location_type] : null;
|
||||
$result['broader_context'] = $requested && count($result['territories']) && $requested->id !== $result['territories'][0]['id'];
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/** @param list<string> $territories
|
||||
* @return array<string,mixed> */
|
||||
public function analyse(array $territories, int $start, int $end, string $sector = 'general', ?string $edition = null): array
|
||||
|
||||
Reference in New Issue
Block a user