Auto-create athlete in startlist for unrecognized bib numbers
Build & Deploy / build-and-deploy (push) Successful in 45s

When a bib number is detected (via OCR or manual entry during review)
but not found in the start list, it is now automatically added with
the placeholder name "Ukjent #<nr>" instead of being left without a
profile_id (which would exclude it from results).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-21 17:51:03 +01:00
parent 99565daafb
commit 018f84efd8
4 changed files with 18 additions and 12 deletions
+8
View File
@@ -150,6 +150,14 @@ async def import_startlist_csv(db: aiosqlite.Connection, csv_content: str) -> di
return {"imported": imported, "errors": errors}
async def get_or_create_athlete(db: aiosqlite.Connection, bib_number: str) -> str:
"""Hent eller opprett utøver basert på startnummer. Returnerer profile_id."""
athlete = await get_athlete_by_bib(db, bib_number)
if athlete:
return athlete["profile_id"]
return await upsert_athlete(db, bib_number, f"Ukjent #{bib_number}")
async def get_athlete_by_bib(db: aiosqlite.Connection, bib: str) -> Optional[dict]:
async with db.execute(
"SELECT * FROM athletes WHERE bib_number = ?", (bib,)