trains: Wikidata/Wikipedia import, Commons photos and refresh scripts
All checks were successful
Deploy production / deploy (push) Successful in 1m13s
All checks were successful
Deploy production / deploy (push) Successful in 1m13s
This commit is contained in:
27
scripts/trains-refresh.sh
Executable file
27
scripts/trains-refresh.sh
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/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
|
||||
Reference in New Issue
Block a user