Bib-registrering direkte i zoom-overlay med Enter-støtte
Build & Deploy / build-and-deploy (push) Successful in 37s
Build & Deploy / build-and-deploy (push) Successful in 37s
- ZoomOverlay: input for startnummer (Enter = legg til, Esc = lukk)
- Kjente bibs fra OCR forhåndsutfylles i overlay
- Bekreft-knapp (antall) løser current passering + oppretter nye for ekstra bibs
- Backend: POST /api/passages/{id}/add-bib oppretter manuell søsken-passering
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -264,6 +264,60 @@ async def remove_passage(passage_id: str, db=Depends(get_connection)):
|
||||
return {"ok": True}
|
||||
|
||||
|
||||
class AddBibRequest(BaseModel):
|
||||
bib_number: str
|
||||
|
||||
|
||||
@app.post("/api/passages/{passage_id}/add-bib")
|
||||
async def add_bib_to_passage(passage_id: str, body: AddBibRequest, db=Depends(get_connection)):
|
||||
"""
|
||||
Opprett en ny passering manuelt fra samme bilde som en eksisterende passering.
|
||||
Brukes når man ser flere løpere i ett bilde under gjennomgang.
|
||||
"""
|
||||
from datetime import timezone as _tz
|
||||
from profile_db import get_or_create_athlete
|
||||
|
||||
async with db.execute("SELECT * FROM passages WHERE passage_id = ?", (passage_id,)) as cur:
|
||||
row = await cur.fetchone()
|
||||
if not row:
|
||||
raise HTTPException(404, "Passering ikke funnet")
|
||||
|
||||
p = dict(row)
|
||||
ts = datetime.fromisoformat(p["timestamp_utc"])
|
||||
if ts.tzinfo is None:
|
||||
ts = ts.replace(tzinfo=_tz.utc)
|
||||
|
||||
profile_id = await get_or_create_athlete(db, body.bib_number)
|
||||
|
||||
new_id = await log_passage(
|
||||
db,
|
||||
race_id=p["race_id"],
|
||||
profile_id=profile_id,
|
||||
bib_number=body.bib_number,
|
||||
station=p["station"],
|
||||
timestamp_utc=ts,
|
||||
gps_lat=p["gps_lat"],
|
||||
gps_lon=p["gps_lon"],
|
||||
gps_alt=p["gps_alt"],
|
||||
confidence=1.0,
|
||||
proximity_score=0.0,
|
||||
id_method="manual",
|
||||
source_image=p["source_image"],
|
||||
needs_review=False,
|
||||
review_note=None,
|
||||
)
|
||||
|
||||
# Oppdater EXIF-metadata
|
||||
from image_tagger import write_bib_tags, read_bib_tags
|
||||
img_path = Path(p["source_image"])
|
||||
if img_path.exists():
|
||||
existing = read_bib_tags(img_path)
|
||||
all_bibs = list(dict.fromkeys((existing or {}).get("bibs", []) + [body.bib_number]))
|
||||
write_bib_tags(img_path, all_bibs, station=p["station"], race_id=p["race_id"], confirmed=True)
|
||||
|
||||
return {"passage_id": new_id, "bib_number": body.bib_number}
|
||||
|
||||
|
||||
@app.post("/api/passages/{passage_id}/reanalyze")
|
||||
async def reanalyze_passage(passage_id: str, db=Depends(get_connection)):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user