Files
gomag-vending/api/app/config.py
Marius Mutu 82196b9dc0 feat(sqlite): refactor orders schema + dashboard period filter
Replace import_orders (insert-per-run) with orders table (one row per
order, upsert on conflict). Eliminates dedup CTE on every dashboard
query and prevents unbounded row growth at 4-500 orders/sync.

Key changes:
- orders table: PK order_number, upsert via ON CONFLICT DO UPDATE;
  COALESCE preserves id_comanda once set; times_skipped auto-increments
- sync_run_orders: lightweight junction (sync_run_id, order_number)
  replaces sync_run_id column on orders
- order_items: PK changed to (order_number, sku), INSERT OR IGNORE
- Auto-migration in init_sqlite(): import_orders → orders on first boot,
  old table renamed to import_orders_bak
- /api/dashboard/orders: period_days param (3/7/30/0=all, default 7)
- Dashboard: period selector buttons in orders card header
- start.sh: stop existing process on port 5003 before restart;
  remove --reload (broken on WSL2 /mnt/e/)
- Add invoice_service, E2E Playwright tests, Oracle package updates

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-13 16:18:57 +02:00

44 lines
1.1 KiB
Python

from pydantic_settings import BaseSettings
from pathlib import Path
import os
# Resolve .env relative to this file (api/app/config.py → api/.env)
_env_path = Path(__file__).resolve().parent.parent / ".env"
class Settings(BaseSettings):
# Oracle
ORACLE_USER: str = "MARIUSM_AUTO"
ORACLE_PASSWORD: str = "ROMFASTSOFT"
ORACLE_DSN: str = "ROA_CENTRAL"
INSTANTCLIENTPATH: str = ""
FORCE_THIN_MODE: bool = False
TNS_ADMIN: str = ""
# SQLite
SQLITE_DB_PATH: str = str(Path(__file__).parent.parent / "data" / "import.db")
# App
APP_PORT: int = 5003
LOG_LEVEL: str = "INFO"
JSON_OUTPUT_DIR: str = ""
# SMTP (optional)
SMTP_HOST: str = ""
SMTP_PORT: int = 587
SMTP_USER: str = ""
SMTP_PASSWORD: str = ""
SMTP_TO: str = ""
# Auth (optional)
API_USERNAME: str = ""
API_PASSWORD: str = ""
# ROA Import Settings
ID_POL: int = 0
ID_GESTIUNE: int = 0
ID_SECTIE: int = 0
model_config = {"env_file": str(_env_path), "env_file_encoding": "utf-8", "extra": "ignore"}
settings = Settings()