Structura repo conform plan.md sect. 4, booteaza cu /healthz verde:
- app/main.py: FastAPI (lifespan init_db), /healthz (worker viu + last login + queue), /metrics
- app/api/v1: POST /v1/prezentari (enqueue + dedup idempotency UNIQUE), GET prezentari/{id}, nomenclator, mapari
- app/rar_client.py: client RAR real (login/JWT, nomenclator, postPrezentare, getFinalizate) cu User-Agent obligatoriu (fix WAF 403)
- app/worker: proces separat, claim atomic BEGIN IMMEDIATE, heartbeat, login+send (send dezactivat by default)
- app/web: dashboard Jinja2+HTMX (coada, banner alerta blocate, worker viu/mort, stari empty)
- app/db.py + schema.sql: SQLite WAL, tabele accounts/api_keys/operations_mapping/nomenclator_rar/submissions/worker_heartbeat
- app/idempotency.py + payload.py: hash continut canonic + builder payload (status FINALIZATA, fara tipPrestatie)
- Dockerfile + docker-compose.yml (api+worker, volum SQLite persistent, restart:always)
- tools/import_dbf.py: stub T5
Verificat live: login prin rar_client OK (token 259), nomenclator 18 coduri, worker heartbeat -> /healthz worker_alive=True.
Ramas: T3 validare Pydantic, T4 snapshot payload, T2 reconciliere/retry worker, T5 import DBF, auth API-key, middleware redactare creds, criptare PII.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
38 lines
1.3 KiB
Python
38 lines
1.3 KiB
Python
#!/usr/bin/env python3
|
|
"""Import DBF -> SQLite (T5 — SCHELET, neimplementat inca).
|
|
|
|
Plan.md sect. 7: dry-run + raport intai (randuri valide, mapari orfane, coduri
|
|
necunoscute in nomenclator), apoi scrie in SQLite. Surse:
|
|
- mapare_prestatii.DBF -> operations_mapping
|
|
- prestatii_rar.DBF -> nomenclator_rar
|
|
(rar_log.DBF NU se migreaza.)
|
|
|
|
Utilizare (cand e implementat):
|
|
python -m tools.import_dbf --dry-run
|
|
python -m tools.import_dbf --commit
|
|
|
|
Necesita: pip install dbfread
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import sys
|
|
|
|
|
|
def main(argv: list[str] | None = None) -> int:
|
|
parser = argparse.ArgumentParser(description="Import DBF ROAAUTO -> SQLite gateway (T5)")
|
|
parser.add_argument("--dry-run", action="store_true", help="raport fara scriere (default)")
|
|
parser.add_argument("--commit", action="store_true", help="scrie in SQLite dupa confirmare")
|
|
parser.parse_args(argv)
|
|
|
|
print("tools/import_dbf.py este SCHELET (T5). De implementat:")
|
|
print(" 1. citeste mapare_prestatii.DBF + prestatii_rar.DBF cu dbfread")
|
|
print(" 2. raport: randuri valide, mapari orfane, coduri necunoscute in nomenclator")
|
|
print(" 3. la --commit: INSERT idempotent in operations_mapping / nomenclator_rar")
|
|
return 1
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|