feat(scores): persist scores in Postgres, add scoreboard UI
Introduces a long-lived `pid` cookie (365 d) as persistent player identity alongside the existing 24 h `sid` session cookie. On first visit, a player row is upserted into `players`. On round end, a transaction inserts into `games` and updates aggregates (best_attempts on wins only, streak counters, last_played_at). DB failures are caught and logged — the game keeps serving. Adds a 3×2 'Your best' stats panel and a public top-10 scoreboard (fewest best_attempts ASC, earliest last_played_at as tie-breaker; identifiers truncated to 8 chars; current player highlighted). Infrastructure: adds `pg` dependency, Dockerfile now installs npm deps before copying server.mjs, docker-compose forwards all provisioned TXT_GAME_DB_* vars and joins the postgres_postgres network for container-to-container reach. Task: d1c49d59-57bd-4eba-9e22-f25a04157ad4
This commit is contained in:
@@ -5,6 +5,11 @@ services:
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- DOMAIN=${DOMAIN:-localhost}
|
||||
- TXT_GAME_DB_HOST=${TXT_GAME_DB_HOST}
|
||||
- TXT_GAME_DB_PORT=${TXT_GAME_DB_PORT}
|
||||
- TXT_GAME_DB_USER=${TXT_GAME_DB_USER}
|
||||
- TXT_GAME_DB_PASSWORD=${TXT_GAME_DB_PASSWORD}
|
||||
- TXT_GAME_DB_NAME=${TXT_GAME_DB_NAME}
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
- "traefik.http.routers.txt-game.rule=Host(`txt.${DOMAIN:-localhost}`)"
|
||||
@@ -13,7 +18,10 @@ services:
|
||||
- "traefik.http.services.txt-game.loadbalancer.server.port=3000"
|
||||
networks:
|
||||
- proxy
|
||||
- postgres_postgres
|
||||
|
||||
networks:
|
||||
proxy:
|
||||
external: true
|
||||
postgres_postgres:
|
||||
external: true
|
||||
|
||||
Reference in New Issue
Block a user