Major database enhancement implementing fast-querying season batting stats: Database Schema: - Created seasonbattingstats table with composite primary key (player_id, season) - All batting stats (counting + calculated): pa, ab, avg, obp, slg, ops, woba, etc. - Proper foreign key constraints and performance indexes - Production-ready SQL creation script included Selective Update System: - update_season_batting_stats() function with PostgreSQL upsert logic - Triggers on game PATCH operations to update affected player stats - Recalculates complete season stats from stratplay data - Efficient updates of only players who participated in modified games API Enhancements: - Enhanced SeasonBattingStats.get_top_hitters() with full filtering support - New /api/v3/views/season-stats/batting/refresh endpoint for season rebuilds - Updated views endpoint to use centralized get_top_hitters() method - Support for team, player, min PA, and pagination filtering Infrastructure: - Production database sync Docker service with SSH automation - Comprehensive error handling and logging throughout - Fixed Peewee model to match actual table structure (no auto-id) - Updated CLAUDE.md with dev server info and sync commands 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
96 lines
2.2 KiB
YAML
96 lines
2.2 KiB
YAML
version: '3'
|
|
|
|
networks:
|
|
nginx-proxy-manager_npm_network:
|
|
external: true
|
|
|
|
services:
|
|
api:
|
|
# build: .
|
|
image: manticorum67/major-domo-database:dev-pg
|
|
restart: unless-stopped
|
|
container_name: sba_db_api
|
|
volumes:
|
|
- ./storage:/usr/src/app/storage
|
|
- ./logs:/usr/src/app/logs
|
|
ports:
|
|
- 801:80
|
|
networks:
|
|
- default
|
|
- nginx-proxy-manager_npm_network
|
|
environment:
|
|
- TESTING=False
|
|
- LOG_LEVEL=${LOG_LEVEL}
|
|
- API_TOKEN=${API_TOKEN}
|
|
- TZ=${TZ}
|
|
- WORKERS_PER_CORE=1.5
|
|
- TIMEOUT=120
|
|
- GRACEFUL_TIMEOUT=120
|
|
- DATABASE_TYPE=postgresql
|
|
- POSTGRES_HOST=sba_postgres
|
|
- POSTGRES_DB=${SBA_DATABASE}
|
|
- POSTGRES_USER=${SBA_DB_USER}
|
|
- POSTGRES_PASSWORD=${SBA_DB_USER_PASSWORD}
|
|
depends_on:
|
|
- postgres
|
|
|
|
postgres:
|
|
image: postgres:17-alpine
|
|
restart: unless-stopped
|
|
container_name: sba_postgres
|
|
environment:
|
|
- POSTGRES_DB=${SBA_DATABASE}
|
|
- POSTGRES_USER=${SBA_DB_USER}
|
|
- POSTGRES_PASSWORD=${SBA_DB_USER_PASSWORD}
|
|
- TZ=${TZ}
|
|
volumes:
|
|
- postgres_data:/var/lib/postgresql/data
|
|
- ./logs:/var/log/postgresql
|
|
ports:
|
|
- "5432:5432"
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U ${SBA_DB_USER} -d ${SBA_DATABASE}"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
start_period: 30s
|
|
|
|
adminer:
|
|
image: adminer:latest
|
|
restart: unless-stopped
|
|
container_name: sba_adminer
|
|
ports:
|
|
- "8080:8080"
|
|
environment:
|
|
- ADMINER_DEFAULT_SERVER=sba_postgres
|
|
- TZ=${TZ}
|
|
# - ADMINER_DESIGN=pepa-linha-dark
|
|
depends_on:
|
|
- postgres
|
|
|
|
sync-prod:
|
|
image: alpine:latest
|
|
container_name: sba_sync_prod
|
|
volumes:
|
|
- ./scripts:/scripts
|
|
- /home/cal/.ssh:/tmp/ssh:ro
|
|
environment:
|
|
- SBA_DB_USER=${SBA_DB_USER}
|
|
- SBA_DATABASE=${SBA_DATABASE}
|
|
- SBA_DB_USER_PASSWORD=${SBA_DB_USER_PASSWORD}
|
|
command: >
|
|
sh -c "
|
|
cp -r /tmp/ssh /root/.ssh &&
|
|
chmod 700 /root/.ssh &&
|
|
chmod 600 /root/.ssh/* &&
|
|
chown -R root:root /root/.ssh &&
|
|
/scripts/sync_from_prod.sh
|
|
"
|
|
profiles: ["sync"]
|
|
depends_on:
|
|
- postgres
|
|
networks:
|
|
- default
|
|
|
|
volumes:
|
|
postgres_data: |