Skip to content

Fix Infra Layer#88

Merged
zigzagdev merged 3 commits into
feature/west-africafrom
feature/west-africa-infra
Aug 31, 2025
Merged

Fix Infra Layer#88
zigzagdev merged 3 commits into
feature/west-africafrom
feature/west-africa-infra

Conversation

@zigzagdev
Copy link
Copy Markdown
Owner

what i have done

  • fix repository and repair insert & insertMany methods
  • fix seeder files

@zigzagdev zigzagdev requested a review from Copilot August 31, 2025 07:23
@zigzagdev zigzagdev self-assigned this Aug 31, 2025
@zigzagdev zigzagdev linked an issue Aug 31, 2025 that may be closed by this pull request
@zigzagdev zigzagdev merged commit 1f6a721 into feature/west-africa Aug 31, 2025
1 check passed
Copy link
Copy Markdown

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 refactors the infrastructure layer to update the database schema and data models from using auto-incrementing IDs to using UNESCO heritage site IDs as primary keys. This change aligns the system more closely with UNESCO's official identification system.

Key changes:

  • Replaced auto-incrementing id with UNESCO site IDs as primary keys in the WorldHeritage model and related code
  • Updated country code standards from ISO2 to ISO3 format throughout the codebase
  • Restructured seeder files to use the new identification system and proper country code mappings

Reviewed Changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
WorldHeritageSeeder.php New seeder file with UNESCO heritage sites using official site IDs
SiteStatePartySeeder.php New seeder for site-country relationships with ISO3 country codes
JapaneseWorldHeritageSeeder.php Removed old seeder file that used different ID scheme
DatabaseSeeder.php Updated to use new seeder classes
CountrySeeder.php Enhanced with ISO2 to ISO3 country code mapping
WorldHeritageRepository.php Updated to use UNESCO IDs instead of auto-incrementing IDs
WorldHeritageEntity.php Removed UNESCO ID field and updated validation patterns
WorldHeritage.php Updated model to use non-incrementing primary key
Test files Updated test data and assertions to match new ID scheme

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

'short_description' => '氷期後のブナの自然拡散史を示すヨーロッパ各地の原生的ブナ林群から成る越境・連続資産。',
'image_url' => null,
'unesco_site_url' => 'https://whc.unesco.org/en/list/1133',
'created_at' => $now, 'updated_at' => $now,
Copy link

Copilot AI Aug 31, 2025

Choose a reason for hiding this comment

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

[nitpick] Missing spaces around array elements makes the code harder to read. Consider formatting as 'created_at' => $now, 'updated_at' => $now.

Copilot uses AI. Check for mistakes.
Comment on lines +19 to +35
['state_party_code'=>'SVK','world_heritage_site_id'=>1133,'is_primary'=>true ,'inscription_year'=>2007,'created_at'=>$now,'updated_at'=>$now],
['state_party_code'=>'DEU','world_heritage_site_id'=>1133,'is_primary'=>false,'inscription_year'=>2011,'created_at'=>$now,'updated_at'=>$now],
['state_party_code'=>'UKR','world_heritage_site_id'=>1133,'is_primary'=>false,'inscription_year'=>2007,'created_at'=>$now,'updated_at'=>$now],
['state_party_code'=>'POL','world_heritage_site_id'=>1133,'is_primary'=>false,'inscription_year'=>2021,'created_at'=>$now,'updated_at'=>$now],
['state_party_code'=>'ROU','world_heritage_site_id'=>1133,'is_primary'=>false,'inscription_year'=>2017,'created_at'=>$now,'updated_at'=>$now],
['state_party_code'=>'CHN','world_heritage_site_id'=>1442,'is_primary'=>true ,'inscription_year'=>2014,'created_at'=>$now,'updated_at'=>$now],
['state_party_code'=>'KAZ','world_heritage_site_id'=>1442,'is_primary'=>false,'inscription_year'=>2014,'created_at'=>$now,'updated_at'=>$now],
['state_party_code'=>'KGZ','world_heritage_site_id'=>1442,'is_primary'=>false,'inscription_year'=>2014,'created_at'=>$now,'updated_at'=>$now],
['state_party_code'=>'UZB','world_heritage_site_id'=>1662,'is_primary'=>true ,'inscription_year'=>2023,'created_at'=>$now,'updated_at'=>$now],
['state_party_code'=>'TJK','world_heritage_site_id'=>1662,'is_primary'=>false,'inscription_year'=>2023,'created_at'=>$now,'updated_at'=>$now],
['state_party_code'=>'TKM','world_heritage_site_id'=>1662,'is_primary'=>false,'inscription_year'=>2023,'created_at'=>$now,'updated_at'=>$now],
['state_party_code'=>'JPN','world_heritage_site_id'=>661 ,'is_primary'=>true,'inscription_year'=>1993,'created_at'=>$now,'updated_at'=>$now],
['state_party_code'=>'JPN','world_heritage_site_id'=>688 ,'is_primary'=>true,'inscription_year'=>1994,'created_at'=>$now,'updated_at'=>$now],
['state_party_code'=>'JPN','world_heritage_site_id'=>662 ,'is_primary'=>true,'inscription_year'=>1993,'created_at'=>$now,'updated_at'=>$now],
['state_party_code'=>'JPN','world_heritage_site_id'=>663 ,'is_primary'=>true,'inscription_year'=>1993,'created_at'=>$now,'updated_at'=>$now],
['state_party_code'=>'JPN','world_heritage_site_id'=>1142,'is_primary'=>true,'inscription_year'=>2004,'created_at'=>$now,'updated_at'=>$now],
['state_party_code'=>'JPN','world_heritage_site_id'=>1418,'is_primary'=>true,'inscription_year'=>2013,'created_at'=>$now,'updated_at'=>$now],
Copy link

Copilot AI Aug 31, 2025

Choose a reason for hiding this comment

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

[nitpick] Inconsistent spacing around array operators and extra space before comma after 'true'. Format consistently as 'key' => 'value' with proper spacing.

Suggested change
['state_party_code'=>'SVK','world_heritage_site_id'=>1133,'is_primary'=>true ,'inscription_year'=>2007,'created_at'=>$now,'updated_at'=>$now],
['state_party_code'=>'DEU','world_heritage_site_id'=>1133,'is_primary'=>false,'inscription_year'=>2011,'created_at'=>$now,'updated_at'=>$now],
['state_party_code'=>'UKR','world_heritage_site_id'=>1133,'is_primary'=>false,'inscription_year'=>2007,'created_at'=>$now,'updated_at'=>$now],
['state_party_code'=>'POL','world_heritage_site_id'=>1133,'is_primary'=>false,'inscription_year'=>2021,'created_at'=>$now,'updated_at'=>$now],
['state_party_code'=>'ROU','world_heritage_site_id'=>1133,'is_primary'=>false,'inscription_year'=>2017,'created_at'=>$now,'updated_at'=>$now],
['state_party_code'=>'CHN','world_heritage_site_id'=>1442,'is_primary'=>true ,'inscription_year'=>2014,'created_at'=>$now,'updated_at'=>$now],
['state_party_code'=>'KAZ','world_heritage_site_id'=>1442,'is_primary'=>false,'inscription_year'=>2014,'created_at'=>$now,'updated_at'=>$now],
['state_party_code'=>'KGZ','world_heritage_site_id'=>1442,'is_primary'=>false,'inscription_year'=>2014,'created_at'=>$now,'updated_at'=>$now],
['state_party_code'=>'UZB','world_heritage_site_id'=>1662,'is_primary'=>true ,'inscription_year'=>2023,'created_at'=>$now,'updated_at'=>$now],
['state_party_code'=>'TJK','world_heritage_site_id'=>1662,'is_primary'=>false,'inscription_year'=>2023,'created_at'=>$now,'updated_at'=>$now],
['state_party_code'=>'TKM','world_heritage_site_id'=>1662,'is_primary'=>false,'inscription_year'=>2023,'created_at'=>$now,'updated_at'=>$now],
['state_party_code'=>'JPN','world_heritage_site_id'=>661 ,'is_primary'=>true,'inscription_year'=>1993,'created_at'=>$now,'updated_at'=>$now],
['state_party_code'=>'JPN','world_heritage_site_id'=>688 ,'is_primary'=>true,'inscription_year'=>1994,'created_at'=>$now,'updated_at'=>$now],
['state_party_code'=>'JPN','world_heritage_site_id'=>662 ,'is_primary'=>true,'inscription_year'=>1993,'created_at'=>$now,'updated_at'=>$now],
['state_party_code'=>'JPN','world_heritage_site_id'=>663 ,'is_primary'=>true,'inscription_year'=>1993,'created_at'=>$now,'updated_at'=>$now],
['state_party_code'=>'JPN','world_heritage_site_id'=>1142,'is_primary'=>true,'inscription_year'=>2004,'created_at'=>$now,'updated_at'=>$now],
['state_party_code'=>'JPN','world_heritage_site_id'=>1418,'is_primary'=>true,'inscription_year'=>2013,'created_at'=>$now,'updated_at'=>$now],
['state_party_code' => 'SVK', 'world_heritage_site_id' => 1133, 'is_primary' => true, 'inscription_year' => 2007, 'created_at' => $now, 'updated_at' => $now],
['state_party_code' => 'DEU', 'world_heritage_site_id' => 1133, 'is_primary' => false, 'inscription_year' => 2011, 'created_at' => $now, 'updated_at' => $now],
['state_party_code' => 'UKR', 'world_heritage_site_id' => 1133, 'is_primary' => false, 'inscription_year' => 2007, 'created_at' => $now, 'updated_at' => $now],
['state_party_code' => 'POL', 'world_heritage_site_id' => 1133, 'is_primary' => false, 'inscription_year' => 2021, 'created_at' => $now, 'updated_at' => $now],
['state_party_code' => 'ROU', 'world_heritage_site_id' => 1133, 'is_primary' => false, 'inscription_year' => 2017, 'created_at' => $now, 'updated_at' => $now],
['state_party_code' => 'CHN', 'world_heritage_site_id' => 1442, 'is_primary' => true, 'inscription_year' => 2014, 'created_at' => $now, 'updated_at' => $now],
['state_party_code' => 'KAZ', 'world_heritage_site_id' => 1442, 'is_primary' => false, 'inscription_year' => 2014, 'created_at' => $now, 'updated_at' => $now],
['state_party_code' => 'KGZ', 'world_heritage_site_id' => 1442, 'is_primary' => false, 'inscription_year' => 2014, 'created_at' => $now, 'updated_at' => $now],
['state_party_code' => 'UZB', 'world_heritage_site_id' => 1662, 'is_primary' => true, 'inscription_year' => 2023, 'created_at' => $now, 'updated_at' => $now],
['state_party_code' => 'TJK', 'world_heritage_site_id' => 1662, 'is_primary' => false, 'inscription_year' => 2023, 'created_at' => $now, 'updated_at' => $now],
['state_party_code' => 'TKM', 'world_heritage_site_id' => 1662, 'is_primary' => false, 'inscription_year' => 2023, 'created_at' => $now, 'updated_at' => $now],
['state_party_code' => 'JPN', 'world_heritage_site_id' => 661, 'is_primary' => true, 'inscription_year' => 1993, 'created_at' => $now, 'updated_at' => $now],
['state_party_code' => 'JPN', 'world_heritage_site_id' => 688, 'is_primary' => true, 'inscription_year' => 1994, 'created_at' => $now, 'updated_at' => $now],
['state_party_code' => 'JPN', 'world_heritage_site_id' => 662, 'is_primary' => true, 'inscription_year' => 1993, 'created_at' => $now, 'updated_at' => $now],
['state_party_code' => 'JPN', 'world_heritage_site_id' => 663, 'is_primary' => true, 'inscription_year' => 1993, 'created_at' => $now, 'updated_at' => $now],
['state_party_code' => 'JPN', 'world_heritage_site_id' => 1142, 'is_primary' => true, 'inscription_year' => 2004, 'created_at' => $now, 'updated_at' => $now],
['state_party_code' => 'JPN', 'world_heritage_site_id' => 1418, 'is_primary' => true, 'inscription_year' => 2013, 'created_at' => $now, 'updated_at' => $now],

Copilot uses AI. Check for mistakes.
Comment on lines +119 to +120
if (!$code3) {
throw new RuntimeException("ISO2 code {$code2} has no ISO3 mapping.");
Copy link

Copilot AI Aug 31, 2025

Choose a reason for hiding this comment

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

The error message could be more helpful by suggesting what action to take. Consider: 'ISO2 code {$code2} has no ISO3 mapping. Please add the mapping to the iso2to3 array.'

Suggested change
if (!$code3) {
throw new RuntimeException("ISO2 code {$code2} has no ISO3 mapping.");
throw new RuntimeException("ISO2 code {$code2} has no ISO3 mapping. Please add the mapping to the iso2to3 array.");

Copilot uses AI. Check for mistakes.
@@ -76,7 +74,7 @@ public function insertHeritage(
}

$heritage->state_party = !empty($codes) ? implode(',', $codes) : null;
Copy link

Copilot AI Aug 31, 2025

Choose a reason for hiding this comment

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

Empty line with no purpose. The removed $heritage->save(); call should either be replaced with an actual save operation or this section needs proper handling of the model persistence.

Copilot uses AI. Check for mistakes.

private function refresh(): void
{
if (env('APP_ENV') === 'testing') {
Copy link

Copilot AI Aug 31, 2025

Choose a reason for hiding this comment

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

Using env() directly in code is not recommended. Use config('app.env') instead or inject the environment through dependency injection.

Suggested change
if (env('APP_ENV') === 'testing') {
if (config('app.env') === 'testing') {

Copilot uses AI. Check for mistakes.
@@ -32,14 +34,16 @@ private function refresh(): void
if (env('APP_ENV') === 'testing') {
Copy link

Copilot AI Aug 31, 2025

Choose a reason for hiding this comment

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

Using env() directly in code is not recommended. Use config('app.env') instead or inject the environment through dependency injection.

Suggested change
if (env('APP_ENV') === 'testing') {
if (config('app.env') === 'testing') {

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix get one world heritage method in QueryService Layer

2 participants