Skip to content

Add study_region to the world heritage import and search flow#357

Merged
zigzagdev merged 3 commits intofeat/introduce-study_regionfrom
chore/integrate-resolver
Mar 14, 2026
Merged

Add study_region to the world heritage import and search flow#357
zigzagdev merged 3 commits intofeat/introduce-study_regionfrom
chore/integrate-resolver

Conversation

@zigzagdev
Copy link
Owner

description

  • add study_region resolution during the world heritage import process
  • populate study_region when importing or updating heritage records
  • keep existing raw region data (region / region_code) unchanged
  • include study_region in the heritage model and Algolia indexing flow
  • add Japanese country mapping config used for study region resolution

what is not included

  • no additional quiz or exam-oriented UI features
  • no changes to the existing raw region classification logic
  • no manual translation work for all heritage descriptions

background

  • the service is intended to support world heritage exam study
  • raw UNESCO region data alone was not sufficient for study use cases
  • study_region was introduced as a separate field so that search and indexing can support exam-oriented grouping without breaking the existing raw region data

confirmation

  • confirmed that study_region is stored in the local DB
  • confirmed that study_region is indexed in Algolia
  • confirmed that existing region values remain unchanged
  • import command completion should be additionally verified with command logs / counts

@zigzagdev zigzagdev requested a review from Copilot March 14, 2026 11:37
@zigzagdev zigzagdev self-assigned this Mar 14, 2026
@zigzagdev zigzagdev linked an issue Mar 14, 2026 that may be closed by this pull request
Copy link
Owner Author

@zigzagdev zigzagdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

@zigzagdev zigzagdev merged commit 7338ac3 into feat/introduce-study_region Mar 14, 2026
27 checks passed
@zigzagdev zigzagdev deleted the chore/integrate-resolver branch March 14, 2026 11:41
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the UNESCO World Heritage import pipeline to enrich records with a study_region, add Japanese country-name resolution, and optionally push imported records to Algolia.

Changes:

  • Added Japanese ISO3→country-name config and fallback resolution during country import.
  • Introduced study_region on world_heritage_sites and populated it during split/import steps.
  • Extended the build command to optionally run an Algolia import, and updated the Algolia import command payload.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
src/config/country_ja.php New ISO3→Japanese country name lookup table used during country import.
src/app/Models/WorldHeritage.php Adds study_region to mass-assignable fields.
src/app/Console/Commands/WorldHeritageBuild.php Adds --algolia/--algolia-truncate options to trigger Algolia indexing after import.
src/app/Console/Commands/SplitWorldHeritageJson.php Adds study_region derivation and modifies normalized site payload fields.
src/app/Console/Commands/ImportWorldHeritageSiteFromSplitFile.php Imports study_region from split JSON and changes bool-int coercion behavior.
src/app/Console/Commands/ImportWorldHeritageFromJson.php Derives study_region via resolver and refactors country/state-party extraction logic.
src/app/Console/Commands/ImportCountriesFromSplitFile.php Resolves missing name_jp via the new country_ja config mapping.
src/app/Console/Commands/AlgoliaImportWorldHeritages.php Refactors Algolia import selection/payload and adds progress/dry-run output.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

'is_endangered' => $toTinyInt($row['danger'] ?? $row['is_endangered'] ?? false),
'latitude' => is_numeric($lat) ? (float) $lat : null,
'longitude' => is_numeric($lon) ? (float) $lon : null,
'year_inscribed' => (isset($row['date_inscribed']) && is_numeric($row['date_inscribed'])) ? (int) $row['date_inscribed'] : null,
Comment on lines +738 to +739
'image_url' => null,
'primary_image_url' => null,
Comment on lines 729 to +733
'state_party' => $stateParty,
'category' => $category,
'criteria' => $criteria,
'year_inscribed' => $year,
'area_hectares' => isset($row['area_hectares']) && is_numeric($row['area_hectares']) ? (float) $row['area_hectares'] : null,
'buffer_zone_hectares' => isset($row['buffer_zone_hectares']) && is_numeric($row['buffer_zone_hectares']) ? (float) $row['buffer_zone_hectares'] : null,
'is_endangered' => $toTinyInt($row['danger'] ?? $row['is_endangered'] ?? false),
'latitude' => is_numeric($lat) ? (float) $lat : null,
'longitude' => is_numeric($lon) ? (float) $lon : null,
'year_inscribed' => (isset($row['date_inscribed']) && is_numeric($row['date_inscribed'])) ? (int) $row['date_inscribed'] : null,
'area_hectares' => isset($row['area_hectares']) ? (is_numeric($row['area_hectares']) ? (float) $row['area_hectares'] : null) : null,
Comment on lines +130 to +136
if ((int) $row->id === 1133) {
dd([
'state_party_codes' => $statePartyCodes,
'country_names_jp' => $countryNamesJp,
'object' => end($objects),
]);
}
Comment on lines 24 to 26
if (!$appId || !$apiKey || !$indexName) {
$this->error('Missing ALGOLIA_APP_ID / ALGOLIA_WRITE_API_KEY / ALGOLIA_INDEX');
return self::FAILURE;
Comment on lines +112 to +113
'study_region' => (string) $row->study_region,
'category' => (string) $row->category,
'countries' => function ($query) {
$query->select(['countries.state_party_code', 'countries.name_jp']);
},
'countries',
Comment on lines +138 to 149
$countryName = $this->extractCountryName($row);
$statePartyIso3 = $this->extractIso3StateParty($row);

return [
'id' => $this->toNullableInt($id),
'official_name' => $row['official_name'] ?? null,
'name' => $row['name_en'] ?? $row['name'] ?? null,
'region' => $row['region_en'] ?? $row['region'] ?? null,
'state_party' => $stateParty,
'state_party' => $statePartyIso3,
'study_region' => StudyRegionResolver::resolve($countryName)->value,
'category' => $row['category'] ?? $row['type'] ?? null,
'criteria' => $row['criteria'] ?? null,
Comment on lines 201 to 205
private function toNullableBoolInt(mixed $v): ?int
{
if ($v === null || $v === '') {
return null;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Integrate resolver into the UNESCO import command

2 participants