Reverse-geocode a general area label for logged searches

Each search now stores an `area_label` (district/town) reverse-geocoded from its
coarsened ~1km lat/lng bucket via postcodes.io, surfaced in the Filament Searches
admin as a sortable/searchable column plus an area filter. Geocoding is cached 30
days per bucket, queries a 2km radius so low-density buckets still match the
default 100m miss, and fails gracefully to null. Adds `searches:backfill-areas`
(scheduled hourly) to label existing rows and retry stragglers.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Ovidiu U
2026-06-12 09:05:03 +01:00
parent 040b2f627e
commit ea22387c9d
10 changed files with 331 additions and 1 deletions

View File

@@ -28,6 +28,11 @@ class SearchResource extends Resource
->label('Searched At')
->dateTime('d M Y H:i')
->sortable(),
TextColumn::make('area_label')
->label('Area')
->placeholder('Unknown')
->searchable()
->sortable(),
TextColumn::make('fuel_type')
->label('Fuel Type')
->badge(),
@@ -67,6 +72,15 @@ class SearchResource extends Resource
'B10' => 'B10',
'HVO' => 'HVO',
]),
SelectFilter::make('area_label')
->label('Area')
->searchable()
->options(fn (): array => Search::query()
->whereNotNull('area_label')
->distinct()
->orderBy('area_label')
->pluck('area_label', 'area_label')
->all()),
])
->recordActions([])
->toolbarActions([]);