Add study_region to the world heritage import and search flow#357
Merged
zigzagdev merged 3 commits intofeat/introduce-study_regionfrom Mar 14, 2026
Merged
Add study_region to the world heritage import and search flow#357zigzagdev merged 3 commits intofeat/introduce-study_regionfrom
zigzagdev merged 3 commits intofeat/introduce-study_regionfrom
Conversation
There was a problem hiding this comment.
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_regiononworld_heritage_sitesand 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; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
description
study_regionresolution during the world heritage import processstudy_regionwhen importing or updating heritage recordsregion/region_code) unchangedstudy_regionin the heritage model and Algolia indexing flowwhat is not included
background
study_regionwas introduced as a separate field so that search and indexing can support exam-oriented grouping without breaking the existing raw region dataconfirmation
study_regionis stored in the local DBstudy_regionis indexed in Algoliaregionvalues remain unchanged