Files
website/scripts/trains-refresh.sh
Stan Runge 8c0fc74283
All checks were successful
Deploy production / deploy (push) Successful in 1m13s
trains: Wikidata/Wikipedia import, Commons photos and refresh scripts
2026-10-25 00:09:07 +00:00

28 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
# Refresh of the train pokedex (/trackers/trains) on stan-ovh.
#
# ssh stan@37.187.157.191 'cd ~/dev/website-trains && git fetch -q && git checkout -q --detach origin/main \
# && bun install --frozen-lockfile >/dev/null && scripts/trains-refresh.sh'
#
# 1. bun scripts/trains-import.ts --report-new rebuilds makers, operators and types from Wikidata + English
# Wikipedia (infobox) and notes which makers/types did not exist before. Dex numbers
# are stable (types are matched by Wikidata id).
# 2. bun scripts/trains-photos.ts --missing finds Wikimedia Commons photos for types that
# have none yet (new ones included) and maker and operator logos that are missing.
# stdout: one JSON report {generatedAt, totals, newMakers, newTypes[] (with photo)}.
# Progress goes to stderr. DB_URL is read from the running app container and never printed.
set -euo pipefail
cd "$(dirname "$0")/.."
if [ -z "${DB_URL:-}" ]; then
DB_URL=$(sudo docker inspect personal-website-app-1 --format '{{range .Config.Env}}{{println .}}{{end}}' |
sed -n 's/^DB_URL=//p' | sed 's/@db:5432/@127.0.0.1:5440/')
export DB_URL
fi
report=$(mktemp /tmp/trains-report.XXXXXX.json)
trap 'rm -f "$report"' EXIT
bun scripts/trains-import.ts --report-new "$@" >"$report"
bun scripts/trains-photos.ts --missing --enrich "$report" --fetch