fix(demography): verify D01-D06 in isolated QA with INE traceability
This commit is contained in:
@@ -34,7 +34,11 @@ final class DemographyController extends Controller
|
||||
}
|
||||
$territories = $service->territories()->orderBy('name')->get(['id', 'name', 'parent_id', 'location_type']);
|
||||
|
||||
return Inertia::render('investment/demography', ['sectorReadings' => app(SectorContentAnalysis::class)->forTerritories($data['territories'] ?? []), 'evidence' => $evidence, 'filters' => $data, 'territories' => $territories, 'sectors' => DemographicEvidence::sectors()]);
|
||||
$sector = $data['sector'] ?? 'general';
|
||||
$slug = ['commerce' => 'comercio-e-servicos', 'tourism' => 'turismo', 'industry' => 'industria', 'agriculture' => 'agronegocio', 'education' => 'educacao', 'health' => 'saude'][$sector] ?? null;
|
||||
$entrySector = $slug ? DB::table('sectors')->where('slug', $slug)->where('is_active', true)->value('slug') : null;
|
||||
|
||||
return Inertia::render('investment/demography', ['entrySector' => $entrySector, 'sectorReadings' => app(SectorContentAnalysis::class)->forTerritories($data['territories'] ?? [], $sector), 'evidence' => $evidence, 'filters' => $data, 'territories' => $territories, 'sectors' => DemographicEvidence::sectors()]);
|
||||
}
|
||||
|
||||
public function management(Request $request, DemographicImport $service): Response|RedirectResponse
|
||||
|
||||
@@ -31,7 +31,7 @@ final class DemographicEvidence
|
||||
/** @return array<string,string> */
|
||||
public static function sectors(): array
|
||||
{
|
||||
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'];
|
||||
return ['commerce' => 'Comércio e serviços', 'tourism' => 'Turismo', '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.
|
||||
@@ -122,7 +122,7 @@ final class DemographicEvidence
|
||||
foreach (array_slice($result['territories'], $i + 1) as $right) {
|
||||
foreach ($left['series'] as $a) {
|
||||
foreach ($right['series'] as $b) {
|
||||
foreach (array_unique([$start, $end]) as $year) {
|
||||
foreach (range($start, $end) as $year) {
|
||||
$isTotal = fn ($r) => $r['year'] === $year && $r['indicator'] === 'population' && $r['age_group'] === 'all' && $r['residence'] === 'all';
|
||||
$x = array_values(array_filter($a['values'], $isTotal))[0] ?? null;
|
||||
$y = array_values(array_filter($b['values'], $isTotal))[0] ?? null;
|
||||
|
||||
@@ -198,7 +198,7 @@ final class SectorContentAnalysis
|
||||
* @param list<string> $ids
|
||||
* @return list<array<string,mixed>>
|
||||
*/
|
||||
public function forTerritories(array $ids): array
|
||||
public function forTerritories(array $ids, string $sector = 'general'): array
|
||||
{
|
||||
if (! app(LegacyContent::class)->available() || $ids === []) {
|
||||
return [];
|
||||
@@ -213,7 +213,9 @@ final class SectorContentAnalysis
|
||||
}
|
||||
$result = [];
|
||||
foreach (config('legacy_content.articles', []) as $slug => $identity) {
|
||||
if ($identity['group'] !== 'turismo') {
|
||||
// Provincial articles currently cover tourism only. Never substitute
|
||||
// those ideas for another economic intention or infer missing offers.
|
||||
if ($sector !== 'tourism' || $identity['group'] !== 'turismo') {
|
||||
continue;
|
||||
}
|
||||
preg_match('/post-(\d+)-/', $identity['external_id'], $match);
|
||||
|
||||
Reference in New Issue
Block a user