Files
rar-autopass/app/nomenclator_seed.py
Claude Agent a6df3b636f feat(T5): editor web mapare operatii (hibrid + fuzzy + on-demand needs_mapping)
T5 reinterpretat: nu import DBF, ci editor web al maparii operatie ROAAUTO ->
cod RAR, cu fuzzy lookup si validare de catre utilizator.

- Contract hibrid: item prestatie accepta cod_prestatie (RAR direct, back-compat)
  SAU cod_op_service+denumire (mapat de gateway prin operations_mapping).
- Ingestie: op intern necunoscut -> submission needs_mapping (nu pleaca la RAR);
  codul rezolvat se scrie inapoi in payload_json -> payload builder + worker neatinse.
- Editor HTMX (_mapari.html + GET /_fragments/mapari, POST /mapari): listeaza
  op-urile nemapate, fuzzy preselecteaza codul RAR, save -> re-rezolvare automata
  (queued / needs_data).
- Fuzzy: rapidfuzz.token_sort_ratio pe denumire normalizata (fara diacritice).
- Nomenclator: seed fallback 18 coduri la boot (offline) + refresh live din worker.
- Cont default id=1 cat timp auth API-key (CORE) nu exista (account_id NULL).
- Endpointuri API: GET /v1/mapari/pending, POST /v1/mapari (respinge cod inexistent).
- 15 teste noi (tests/test_mapping.py); 69 pass total.
- Contract actualizat (docs/api-rar-contract.md), rapidfuzz==3.14.5 in requirements.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-15 19:25:21 +00:00

34 lines
1.6 KiB
Python

"""Seed fallback pentru nomenclator_rar.
Nomenclatorul autoritativ se ia LIVE din RAR (`getNomenclatorPrestatii`) si e
upsert-at de worker la fiecare login (vezi worker.refresh_nomenclator). Dar
editorul de mapari + fuzzy lookup trebuie sa functioneze si inainte ca worker-ul
sa fi rulat (dev, offline, primul boot). De aceea seed-uim aceste 18 coduri din
contract (docs/api-rar-contract.md, verificat live 2026-06-15) DOAR daca tabela
e goala; refresh-ul live le suprascrie cu textul lung oficial.
"""
from __future__ import annotations
# (cod_prestatie, nume_prestatie) — 18 coduri, conform contractului live.
FALLBACK_NOMENCLATOR: list[tuple[str, str]] = [
("OE-1", "REPARATIE"),
("OE-2", "INTRETINERE"),
("OE-3", "REVIZIE PERIODICA"),
("OE-4", "REGLARE FUNCTIONALA"),
("OE-5", "MODIFICARE CONSTRUCTIVA"),
("OE-6", "RECONSTRUCTIE"),
("OE-7", "ACTUALIZARE SOFTWARE"),
("OE-8", "INLOCUIRE SEZONIERA A ANVELOPELOR"),
("OE-D", "AVARII GRAVE LA SISTEMUL DE DIRECTIE"),
("OE-F", "AVARII GRAVE LA SISTEMUL DE FRANARE"),
("OE-C", "AVARII GRAVE LA STRUCTURA DE REZISTENTA A CAROSERIEI"),
("OE-S", "AVARII GRAVE LA STRUCTURA DE REZISTENTA A SASIULUI"),
("OE-R", "AVARII GRAVE LA UN SISTEM DE RETINERE SI PROTECTIE IN CAZ DE ACCIDENT"),
("OE-A", "AVARII GRAVE LA UN SISTEM AVANSAT DE ASISTENTA A CONDUCATORULUI AUTO (ADAS)"),
("OE-I", "ISTORICUL INDICATIEI ODOMETRULUI (vehicule anterior inmatriculate in alte tari)"),
("AITLV", "INREGISTRARE ATELIER INSPECTIE TAHOGRAFE / LIMITATOARE DE VITEZA"),
("R-ODO", "REPARATIE ODOMETRU"),
("I-ODO", "INLOCUIRE ODOMETRU"),
]