Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 25 additions & 11 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
version: '3.8'

services:
app:
build:
context: .
dockerfile: ./environment/local/docker/Dockerfile
image: wha-api:local
container_name: heritage-app
ports:
- "8700:8080"
environment:
Expand All @@ -14,10 +16,9 @@ services:
working_dir: /var/www
volumes:
- ./src:/var/www
- vendor_data:/var/www/vendor
- cache_data:/var/www/bootstrap/cache
- composer_cache:/var/www/.composer
networks: [ heritage-net ]
command: tail -f /dev/null
networks:
- heritage-net

mysql:
image: mysql:8.0
Expand All @@ -32,7 +33,21 @@ services:
volumes:
- db_data:/var/lib/mysql
- ./environment/mysql-init:/docker-entrypoint-initdb.d:ro
networks: [ heritage-net ]
networks:
- heritage-net

mysql_test:
image: mysql:8.0
container_name: heritage-mysql-test
environment:
MYSQL_ROOT_PASSWORD: world-heritage
MYSQL_USER: world-heritage
MYSQL_PASSWORD: world-heritage
MYSQL_DATABASE: world_heritage_test
ports:
- "2307:3306"
networks:
- heritage-net

phpmyadmin:
image: phpmyadmin/phpmyadmin:latest
Expand All @@ -44,14 +59,13 @@ services:
PMA_PASSWORD: world-heritage
ports:
- "127.0.0.1:8081:80"
depends_on: [ mysql ]
networks: [ heritage-net ]
depends_on:
- mysql
networks:
- heritage-net

networks:
heritage-net:

volumes:
db_data:
vendor_data:
cache_data:
composer_cache:
db_data:
22 changes: 20 additions & 2 deletions src/app/Console/Commands/AlgoliaImportWorldHeritages.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Algolia\AlgoliaSearch\Api\SearchClient;
use App\Models\WorldHeritage;
use Illuminate\Console\Command;
use App\Support\StudyRegionResolver;

class AlgoliaImportWorldHeritages extends Command
{
Expand Down Expand Up @@ -100,6 +101,21 @@ public function handle(): int
$countryNameJp = $countryNamesJp[0] ?? null;
}

$resolvedStudyRegions = StudyRegionResolver::resolveManyFromRecord(
siteId: (int) $row->id,
country: $country,
statePartyCodes: $statePartyCodes,
);

$studyRegions = array_map(
static fn ($region) => $region->value,
$resolvedStudyRegions
);

$primaryStudyRegion = count($studyRegions) === 1
? $studyRegions[0]
: null;

$objects[] = [
'objectID' => (string) $row->id,
'id' => (int) $row->id,
Expand All @@ -109,12 +125,13 @@ public function handle(): int
'country' => $country,
'country_name_jp' => $countryNameJp,
'region' => (string) $row->region,
'study_region' => (string) $row->study_region,
'study_region' => $primaryStudyRegion,
'study_regions' => $studyRegions,
'category' => (string) $row->category,
'year_inscribed' => $row->year_inscribed !== null ? (int) $row->year_inscribed : null,
'is_endangered' => (bool) $row->is_endangered,
'thumbnail_url' => $row->image_url !== null ? (string) $row->image_url : null,
'state_party_codes' => $countryCount > 1 ? $statePartyCodes : [],
'state_party_codes' => $statePartyCodes,
'country_names_jp' => $countryCount > 1 ? $countryNamesJp : [],
];
}
Expand All @@ -127,6 +144,7 @@ public function handle(): int
$processed += count($objects);
return;
}

if ((int) $row->id === 1133) {
dd([
'state_party_codes' => $statePartyCodes,
Expand Down
8 changes: 1 addition & 7 deletions src/app/Console/Commands/DumpUnescoWorldHeritageJson.php
Original file line number Diff line number Diff line change
Expand Up @@ -456,14 +456,12 @@ private function normalizeRow(array $row): array
'name_ru' => $row['name_ru'] ?? null,
'name_ar' => $row['name_ar'] ?? null,
'name_zh' => $row['name_zh'] ?? null,

'short_description_en' => $row['short_description_en'] ?? null,
'short_description_fr' => $row['short_description_fr'] ?? null,
'short_description_es' => $row['short_description_es'] ?? null,
'short_description_ru' => $row['short_description_ru'] ?? null,
'short_description_ar' => $row['short_description_ar'] ?? null,
'short_description_zh' => $row['short_description_zh'] ?? null,

'description_en' => $row['description_en'] ?? null,
'justification_en' => $row['justification_en'] ?? null,
'criteria' => $row['criteria_txt'] ?? null,
Expand All @@ -473,19 +471,15 @@ private function normalizeRow(array $row): array
'date_end' => $row['date_end'] ?? null,
'danger_list' => $row['danger_list'] ?? null,
'area_hectares' => $toFloat($row['area_hectares'] ?? null),

'category' => $row['category'] ?? null,
'category_id' => $toInt($row['category_id'] ?? null),

'states_names' => is_array($row['states_names'] ?? null) ? $row['states_names'] : [],
'iso_codes' => $row['iso_codes'] ?? null,
'region' => $row['region'] ?? null,
'region_code' => $row['region_code'] ?? null,
'transboundary' => $toBool($row['transboundary'] ?? null),

'image_url' => $row['image_url'] ?? null,
'image_url' => $row['main_image_url'] ?? null,
'images_urls' => $images,

'uuid' => $row['uuid'] ?? null,
'id_no' => $row['id_no'] ?? null,
'coordinates' => $row['coordinates'] ?? null,
Expand Down
2 changes: 1 addition & 1 deletion src/app/Console/Commands/ImportWorldHeritageFromJson.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ private function mapFromUnescoApiRow(array $row): array
'name' => $row['name_en'] ?? $row['name'] ?? null,
'region' => $row['region_en'] ?? $row['region'] ?? null,
'state_party' => $statePartyIso3,
'study_region' => StudyRegionResolver::resolve($countryName)->value,
'study_region' => StudyRegionResolver::resolveFromCountry($countryName)->value,
'category' => $row['category'] ?? $row['type'] ?? null,
'criteria' => $row['criteria'] ?? null,
'year_inscribed' => $this->toNullableInt($row['date_inscribed'] ?? $row['year_inscribed'] ?? null),
Expand Down
8 changes: 4 additions & 4 deletions src/app/Console/Commands/SplitWorldHeritageJson.php
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ private function normalizeSiteRowImportReady(array $row, int $siteId): array
'name' => $this->stringOrFallback($row['name_en'] ?? null, (string) $siteId),
'name_jp' => $this->stringOrNull($row['name_jp'] ?? null),
'study_region' => $countryName
? StudyRegionResolver::resolve($countryName)->value
? StudyRegionResolver::resolveFromCountry($countryName)->value
: null,
'country' => $country,
'region' => $region,
Expand All @@ -735,8 +735,8 @@ private function normalizeSiteRowImportReady(array $row, int $siteId): array
'latitude' => isset($lat) ? (is_numeric($lat) ? (float) $lat : null) : null,
'longitude' => isset($lon) ? (is_numeric($lon) ? (float) $lon : null) : null,
'short_description' => $this->stringOrNull($row['short_description_en'] ?? null),
'image_url' => null,
'primary_image_url' => null,
'image_url' => $this->stringOrNull($row['image_url'] ?? null),
'primary_image_url' => $this->stringOrNull($row['image_url'] ?? null),
'unesco_site_url' => $this->stringOrNull($row['unesco_site_url'] ?? ($row['url'] ?? null)),
];
}
Expand All @@ -748,7 +748,7 @@ private function mergeSiteRowPreferExisting(array $existing, array $incoming): a
$countryName = $stateNames[0] ?? null;

if ($countryName) {
$existing['study_region'] = StudyRegionResolver::resolve($countryName)->value;
$existing['study_region'] = StudyRegionResolver::resolveFromCountry($countryName)->value;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function search(
* Region filter (exact match).
*/
if ($this->hasValue($query->region)) {
$filters[] = 'region:"' . $this->escapeForQuotedString($query->region) . '"';
$filters[] = 'study_region:"' . $this->escapeForQuotedString($query->region) . '"';
}

/**
Expand Down
48 changes: 48 additions & 0 deletions src/app/Packages/Domains/StudyRegion/CountryAliases.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

namespace App\Packages\Domains\StudyRegion;

class CountryAliases
{
public const MAPPING = [
'United States of America' => 'United States',
'USA' => 'United States',

'Russian Federation' => 'Russia',

'Republic of Korea' => 'South Korea',
'Korea, Republic of' => 'South Korea',

'Democratic People\'s Republic of Korea' => 'North Korea',
'Korea (Democratic People\'s Republic of)' => 'North Korea',

'Republic of Moldova' => 'Moldova',

"Côte d’Ivoire" => "Cote d'Ivoire",
"Côte d'Ivoire" => "Cote d'Ivoire",

'Lao People\'s Democratic Republic' => 'Laos',
'Syrian Arab Republic' => 'Syria',
'Türkiye' => 'Turkey',

'Viet Nam' => 'Vietnam',
'Czechia' => 'Czech Republic',

'United Kingdom of Great Britain and Northern Ireland' => 'United Kingdom',
'Netherlands (Kingdom of the)' => 'Netherlands',
'Bolivia (Plurinational State of)' => 'Bolivia',
'Venezuela (Bolivarian Republic of)' => 'Venezuela',

'Iran (Islamic Republic of)' => 'Iran',
'Micronesia (Federated States of)' => 'Federated States of Micronesia',
'Palestine, State of' => 'Palestine',
'State of Palestine' => 'Palestine',
'United Republic of Tanzania' => 'Tanzania',
'North Macedonia' => 'North Macedonia',
'The former Yugoslav Republic of Macedonia' => 'North Macedonia',

'Holy See' => 'Vatican City',
'Congo' => 'Republic of the Congo',
'Cabo Verde' => 'Cape Verde',
];
}
Loading
Loading