fix(demography): verify D01-D06 in isolated QA with INE traceability

This commit is contained in:
2026-11-20 20:07:16 +02:00
parent 558c11ef17
commit 3f66201cbe
17 changed files with 570 additions and 89 deletions
+2 -2
View File
@@ -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;
+4 -2
View File
@@ -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);