All checks were successful
Deploy production / deploy (push) Successful in 1m9s
38 lines
1.9 KiB
Bash
Executable File
38 lines
1.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Weekly-ish refresh of the car pokedex (/trackers/cars) on stan-ovh.
|
|
#
|
|
# ssh stan@37.187.157.191 'cd ~/dev/website-cars && git fetch -q && git checkout -q --detach origin/main \
|
|
# && bun install --frozen-lockfile >/dev/null && scripts/cars-refresh.sh'
|
|
#
|
|
# 1. bun scripts/cars-import.ts --report-new rebuilds brands/models/variants from RDW +
|
|
# fueleconomy.gov and notes which brands/models did not exist before.
|
|
# 2. bun scripts/cars-photos.ts --missing finds Wikimedia Commons photos for models
|
|
# that have none yet (new ones included).
|
|
# 3. bun scripts/spotters-activity.ts cars refreshes the per-country activity scores
|
|
# ("most active in NL" sort; see that script).
|
|
# 4. bun scripts/spotters-logos.ts cars --new logos for new brands / makers / operators
|
|
# (Wikidata logo or icon, then Wikipedia infobox logos)
|
|
# stdout: one JSON report {generatedAt, totals, newBrands, newModels[] (with photo)}, plus `nl` per new
|
|
# entry and `newInNl` (new entries that are active in the Netherlands, see
|
|
# scripts/spotters-report-nl.ts). --report-new is accepted (the report is always printed).
|
|
# 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
|
|
|
|
args=()
|
|
for a in "$@"; do [ "$a" = "--report-new" ] || args+=("$a"); done
|
|
|
|
report=$(mktemp /tmp/cars-report.XXXXXX.json)
|
|
trap 'rm -f "$report"' EXIT
|
|
|
|
bun scripts/cars-import.ts --report-new "${args[@]}" >"$report"
|
|
bun scripts/spotters-activity.ts cars >&2
|
|
bun scripts/spotters-logos.ts cars --new >&2
|
|
bun scripts/cars-photos.ts --missing --enrich "$report" --fetch | bun scripts/spotters-report-nl.ts cars
|