Skip to content

feat(geo): extract country from geo locations and add world map#822

Open
vcnainala wants to merge 6 commits into
developmentfrom
feat/695-geo-location-country-extraction
Open

feat(geo): extract country from geo locations and add world map#822
vcnainala wants to merge 6 commits into
developmentfrom
feat/695-geo-location-country-extraction

Conversation

@vcnainala

Copy link
Copy Markdown
Member

Summary

  • Add rule-based country extraction from geo_locations.name with configurable aliases, Mexican state heuristics, and Nominatim geocoding fallback
  • Centralize geo location creation in GeoLocationService and enrich country metadata during imports
  • Add coconut:enrich-geo-locations artisan command for backfilling existing records
  • Add public /globe choropleth page visualizing molecule, organism, and geo-location counts by country

Closes #695

Implementation notes

  • Uses rinvex/countries (already in the project) for ISO codes and flag emoji
  • Bulk imports use rules-only enrichment; geocoding is deferred to the backfill command to avoid API rate limits
  • Nominatim is used instead of Google Places API for open geocoding with caching and rate limiting

Test plan

  • ./vendor/bin/sail test tests/Unit/GeoLocationCountryExtractorTest.php tests/Unit/NominatimGeocoderTest.php
  • ./vendor/bin/sail artisan coconut:enrich-geo-locations --dry-run --rules-only
  • ./vendor/bin/sail artisan coconut:enrich-geo-locations --rules-only
  • Visit /globe and verify choropleth, metric toggles, and hover panel
  • Confirm new imports populate country_code via GeoLocationService

vcnainala added 6 commits June 8, 2026 21:41
Relax unique-name validation in the request-changes organism repeater so
users can link organisms that already exist in the database. Reject names
already attached to the target molecule instead.

Fixes #772
Align Filament v4 Select option keys with stored state for existing
synonyms, CAS, geo locations, organisms, and citations. Resolve the
target molecule from form state and report records so options remain
valid on Livewire submit requests.

Fixes #775
Use explicit null checks for molecule synonyms/CAS options and remove
unreachable is_string handling for mol_ids array cast.
Introduce rule-based country parsing from geo location names with
Nominatim fallback, backed by config-driven aliases and unit tests.

Refs #695
Centralize geo location creation in GeoLocationService and add
coconut:enrich-geo-locations for backfilling country metadata.

Refs #695
Add a public /globe page with country-level molecule, organism, and
geo-location stats using globe.gl choropleth visualization.

Refs #695
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 46.11111% with 194 lines in your changes missing coverage. Please review.
✅ Project coverage is 7.93%. Comparing base (4223a58) to head (1e897ad).

Files with missing lines Patch % Lines
...pp/Filament/Dashboard/Resources/ReportResource.php 21.73% 54 Missing ⚠️
app/Services/GeoLocationGlobeStatsService.php 0.00% 38 Missing ⚠️
app/Services/GeoLocationEnricher.php 0.00% 25 Missing ⚠️
app/Services/GeoLocationService.php 0.00% 18 Missing ⚠️
app/Services/NominatimGeocoder.php 75.67% 18 Missing ⚠️
app/Services/GeoLocationEnrichmentResult.php 14.28% 12 Missing ⚠️
app/Services/GeoLocationCountryExtractor.php 88.63% 10 Missing ⚠️
app/Models/Organism.php 59.09% 9 Missing ⚠️
app/Livewire/GeoGlobe.php 0.00% 6 Missing ⚠️
app/Jobs/ImportEntryAuto.php 0.00% 3 Missing ⚠️
... and 1 more
Additional details and impacted files
@@               Coverage Diff                @@
##             development    #822      +/-   ##
================================================
+ Coverage           6.13%   7.93%   +1.79%     
- Complexity          1737    1831      +94     
================================================
  Files                227     234       +7     
  Lines               8961    9276     +315     
================================================
+ Hits                 550     736     +186     
- Misses              8411    8540     +129     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants