Skip to content

Geocoding Cron Job#76

Merged
tqmsh merged 5 commits intouwblueprint:TQ/geocoding-refresh-cron-jobfrom
Yujie-Meng:main
Jan 12, 2026
Merged

Geocoding Cron Job#76
tqmsh merged 5 commits intouwblueprint:TQ/geocoding-refresh-cron-jobfrom
Yujie-Meng:main

Conversation

@Yujie-Meng
Copy link
Contributor

@Yujie-Meng Yujie-Meng commented Jan 8, 2026

JIRA ticket link

Geocoding refresh cron job

Implementation description

  • Geocoding Update

The system includes an automated geocoding refresh cron job that updates location coordinates using the Google Maps Geocoding API.

Features

  • Automatic refresh of location coordinates that are NULL or older than 30 days
  • Respects route_archive_after setting in admin_info (default: 30 days)
  • Scheduled job that runs daily at midnight EST
  • Manual trigger via API endpoint

Steps to test

Seed the database with test locations for geocoding:

docker-compose exec backend python -w /app app/seed_geocoding_test_data.py

Before Update

Locations with NULL coordinates or stale geocoding data:

before_test

After Update

Locations with refreshed coordinates from Google Geocoding API:

after_test

What should reviewers focus on?

Checklist

  • My PR name is descriptive and in imperative tense
  • My commit messages are descriptive and in imperative tense. My commits are atomic and trivial commits are squashed or fixup'd into non-trivial commits
  • I have requested a review from the PL, as well as other devs who have background knowledge on this PR or who will be building on top of this PR

- Add route_archive_after field to admin_info table (default: 30 days)
- Add geocoded_at field to locations table to track when address was geocoded
- Set geocoded_at timestamp when creating locations with coordinates
- Create daily cron job to refresh geocoding for locations older than threshold
- Fix scheduler service to handle event loop isolation for async jobs
- Add database migration for new fields

The cron job runs daily at 2 AM and refreshes lat/lon for locations where
geocoded_at is NULL or older than route_archive_after days from admin settings.
- Added a new section detailing the automated geocoding refresh cron job.
- Included features of the geocoding update, such as automatic refresh and manual trigger.
- Added test data instructions and before/after screenshots to illustrate the geocoding process.
- Introduced `_get_archive_threshold`, `_get_locations_to_refresh`, and `_refresh_locations` to modularize the geocoding refresh process.
- Updated `refresh_geocoding` to utilize these new functions for improved readability and maintainability.
- Removed redundant code and streamlined the process of fetching and refreshing location data.
@tqmsh tqmsh merged commit 38f78bb into uwblueprint:TQ/geocoding-refresh-cron-job Jan 12, 2026
1 check failed
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