feat(import): add WSDC list parser with location + update-missing-location option\n\n- Parse Event List for name/date/location/country/sourceUrl\n- Support --source list|calendar|auto and --update-missing-location\n- Keep calendar import for title/start/end/url fallback\n- Update CLI summary and docs (ADMIN_CLI.md, README.md)

This commit is contained in:
Radosław Gierwiało
2025-11-15 21:56:05 +01:00
parent 457de6c1c4
commit b9d6f42ff5
4 changed files with 175 additions and 21 deletions

View File

@@ -1,6 +1,6 @@
# Admin CLI & REPL — spotlight.cam
Administrative console for maintenance tasks inside the backend container. Provides both one-shot commands and an interactive REPL with app context.
Administrative console for maintenance tasks inside the backend container. Provides both oneshot commands and an interactive REPL with app context.
---
@@ -23,17 +23,32 @@ With Makefile shortcuts:
- Default entry: running `npm run cli` starts a Node.js REPL with:
- `prisma` client and `bcrypt` in context
- Aliases: `u = prisma.user`, `e = prisma.event`, `m = prisma.match`, `ep = prisma.eventParticipant`, `r = prisma.rating`
- Top-level await: `await u.findMany({ take: 5 })`
- Toplevel await: `await u.findMany({ take: 5 })`
- Autocomplete (TAB) from Node REPL
- Persistent history in `.repl_history` (best-effort)
- Persistent history in `.repl_history` (besteffort)
- Run CLI subcommands from inside REPL:
- `.cli users:list --limit 20`
- `run('events:checkin --username john_doe --slug warsaw-dance-2025')`
- Error handling: CLI errors (e.g., missing flags) do not exit the REPL; the error is printed and you can correct the command and retry.
---
## Commands
### Cheatsheet
- `repl`
- `users:list [--limit <n>]`
- `users:create --email <e> --username <u> --password <p> [--first <f>] [--last <l>]`
- `users:verify --email <e>`
- `events:list [--limit <n>]`
- `events:details --slug <slug>`
- `events:participants --slug <slug> [--limit <n>] [--csv]`
- `events:import:wsdc [--dry-run] [--since YYYY-MM-DD] [--until YYYY-MM-DD] [--limit <n>]`
- `matches:list [--limit <n>] [--status pending|accepted|completed]`
- `events:checkin --username <u> --slug <s>`
- `logs:app [--lines <n>]`
- `logs:messages [--limit <n>]`
### users:list
- Description: List users
- Options:
@@ -106,16 +121,24 @@ With Makefile shortcuts:
- `npm run cli -- events:participants --slug warsaw-dance-2025 --limit 200 --csv > participants.csv`
### events:import:wsdc
- Description: Import events from worldsdc.com calendar page.
- Notes: Uses the calendars embedded data (title/start/end/url). Does not set `participants` or `worldsdcId`.
- Description: Import events from worldsdc.com.
- Sources:
- `--source list`: parse Event List page (includes Event Location + Country)
- `--source calendar`: parse Events Calendar page (title/start/end/url)
- `--source auto` (default): try calendar first, then list if calendar parsing yields no events
- Options:
- `--dry-run`: show what would be created without writing to DB
- `--since YYYY-MM-DD`: only events on/after date
- `--until YYYY-MM-DD`: only events on/before date
- `--limit <n>`: limit considered items after filtering
- `--update-missing-location`: when an event already exists and its `location` is empty/"Unknown", update it from the imported source (list recommended)
- Examples:
- `npm run cli -- events:import:wsdc --dry-run --since 2024-01-01 --until 2024-12-31`
- `npm run cli -- events:import:wsdc --limit 50`
- `npm run cli -- events:import:wsdc --source list --limit 50`
- `npm run cli -- events:import:wsdc --source list --update-missing-location`
- Field mapping: `name`, `startDate`, `endDate`, `sourceUrl`, `location` (from list) or `Unknown` (from calendar). No updates to `participantsCount`.
- Dedup strategy: skip when `(name, startDate)` already exists.
- Alias: `events:import:worldsdc` (kept for backwards compatibility).
### logs:app
- Description: Tail application log file (if configured)
@@ -147,3 +170,10 @@ With Makefile shortcuts:
- CLI has full DB access; restrict usage to SSH + container exec
- Do not expose CLI via HTTP endpoints
- Consider audit logs for sensitive actions if needed
---
## Domain Notes
- In spotlight.cam, `participantsCount` reflects local checkins (EventParticipants), not official WSDC participant metrics.
- The WSDC calendar source does not provide reliable location or participant counts; importer intentionally does not set `worldsdcId` or `participantsCount`.