Add nightly town sync with autocomplete on journey fields #12

Merged
timmybee merged 2 commits from feature/town-sync into master 2026-03-06 12:24:19 +08:00
Owner

Summary

  • Adds a towns table synced nightly from the ArcGIS Town Point API (1,977 towns)
  • SyncTowns job paginates the API in batches of 1000, upserting by town_pid and handling retired towns via date_retired
  • Scheduled to run at 02:00 every night via routes/console.php
  • /towns/search endpoint returns up to 10 matching active towns filtered by name prefix and optional state
  • Alpine.js autocomplete on origin and destination fields in the travel request form — shows suggestions as you type (300ms debounce)
  • State filter dropdown in the journeys card header lets users narrow autocomplete results to a specific state

Test plan

  • Run php artisan migrate to create the towns table
  • Dispatch the job manually: php artisan tinkerdispatch(new App\Jobs\SyncTowns) and process queue — confirm towns are populated
  • Verify php artisan schedule:list shows SyncTowns running daily at 02:00
  • On the create travel request form, type 2+ characters in Origin or Destination — suggestions should appear
  • Select a suggestion — field should populate with the town name
  • Set the state filter to e.g. WA — autocomplete should only return WA towns
  • Confirm free-text entry still works if the town is not in the database
## Summary - Adds a `towns` table synced nightly from the ArcGIS Town Point API (1,977 towns) - `SyncTowns` job paginates the API in batches of 1000, upserting by `town_pid` and handling retired towns via `date_retired` - Scheduled to run at 02:00 every night via `routes/console.php` - `/towns/search` endpoint returns up to 10 matching active towns filtered by name prefix and optional state - Alpine.js autocomplete on origin and destination fields in the travel request form — shows suggestions as you type (300ms debounce) - State filter dropdown in the journeys card header lets users narrow autocomplete results to a specific state ## Test plan - [ ] Run `php artisan migrate` to create the `towns` table - [ ] Dispatch the job manually: `php artisan tinker` → `dispatch(new App\Jobs\SyncTowns)` and process queue — confirm towns are populated - [ ] Verify `php artisan schedule:list` shows `SyncTowns` running daily at 02:00 - [ ] On the create travel request form, type 2+ characters in Origin or Destination — suggestions should appear - [ ] Select a suggestion — field should populate with the town name - [ ] Set the state filter to e.g. WA — autocomplete should only return WA towns - [ ] Confirm free-text entry still works if the town is not in the database
timmybee added 1 commit 2026-03-06 12:17:32 +08:00
Add nightly town sync from ArcGIS API with autocomplete
All checks were successful
linter / quality (pull_request) Successful in 1m21s
security / Dependency Audit (pull_request) Successful in 1m25s
security / Static Analysis (pull_request) Successful in 1m49s
tests / ci (8.4) (pull_request) Successful in 1m23s
tests / ci (8.5) (pull_request) Successful in 1m27s
a37ada96e2
- Add towns table with town_pid, town_name, state, population, town_class, date_retired
- Add AustralianState enum with label and abbreviation helpers
- Add Town model with active() and search() scopes
- Add SyncTowns job that paginates ArcGIS API and upserts all 1977 towns
- Schedule SyncTowns to run nightly at 02:00
- Add /towns/search endpoint returning JSON suggestions filtered by name and state
- Add Alpine-powered autocomplete on origin/destination fields in create form
- Add state filter dropdown in journeys card header to narrow autocomplete results
timmybee added 1 commit 2026-03-06 12:22:56 +08:00
Add tests for town sync job and search endpoint
All checks were successful
linter / quality (pull_request) Successful in 1m37s
security / Dependency Audit (pull_request) Successful in 1m36s
security / Static Analysis (pull_request) Successful in 1m25s
tests / ci (8.4) (pull_request) Successful in 1m57s
tests / ci (8.5) (pull_request) Successful in 1m31s
72fb80b673
- SyncTownsTest: covers API syncing, pagination, upsert, retired towns, error logging, and success logging
- TownSearchTest: covers auth requirement, min query length, prefix matching, state filtering, retired town exclusion, result limit, response shape, and ordering
- Update TownFactory with retired() and inState() states
timmybee merged commit 35723fb226 into master 2026-03-06 12:24:19 +08:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: timmybee/travel#12