Skip to content

Refresh the saved sources weekly, downloading only what changed - #3

Merged
davd-gzl merged 1 commit into
mainfrom
refresh-sources
Oct 23, 2026
Merged

davd-gzl merged 1 commit into
mainfrom
refresh-sources

Conversation

@davd-gzl

@davd-gzl davd-gzl commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Before: cities, regions, countries and UNESCO sites came from copies frozen on the day they were vendored (npm packages and gzipped files), and only a manual run could update them.

After: a weekly workflow (Sunday, the day before the build) looks for a newer version of each source and commits a new saved copy only when the part used here changed. The built files are unchanged by this PR.

How it stays polite and safe:

  • One conditional request per source, no retries: GeoNames by ETag and date (and only in the first week of the month, since its files change daily), mledoze/countries by GitHub's content hash, UNESCO by its dataset's "modified" date before the list itself is fetched.
  • A download whose SHA-256 matches the last one is skipped, and a saved copy is rewritten only when its content changed. data/reference/sources.lock.json records what was seen.
  • Nothing is forced: a source that can't be reached, answers oddly or loses more than 5% of its records keeps its saved copy, and the script exits 0. A change is checked (npm run check and a build) before it is committed; a commit from the workflow doesn't start a build, the Monday one picks it up.
  • Ids never change: a city GeoNames stops listing is kept, and UNESCO sites keep their ids in data/reference/heritage-ids.json by site number, even when renamed.

Also: all-the-cities, world-countries and the city-admin1 script are gone. Cities now come from GeoNames' cities1000 directly, so the first refresh will add the cities listed since the old package's snapshot. The first countries refresh will rename CG "Congo" in names.json (mledoze's current name); article-names.json keeps "Republic of the Congo", the article title.

Note: the workflow pushes to main with the built-in token, so Actions needs write permission in the repository settings if it is restricted.

Cities, regions, countries and UNESCO sites are now built from saved copies in
data/reference/ that npm run refresh keeps current: one conditional request per
source (GeoNames once a month), a download only when the source changed, and a
new saved copy only when the part used here changed. A source that fails or
shrinks by more than 5% keeps its saved copy. Ids never change: dropped cities
are kept and UNESCO sites keep their ids by site number.

The built files are unchanged. all-the-cities and world-countries are no longer
needed, nor the city-admin1 script.
@davd-gzl
davd-gzl merged commit 7831453 into main Oct 23, 2026
2 checks passed
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.

1 participant