Auto-create athlete in startlist for unrecognized bib numbers
Build & Deploy / build-and-deploy (push) Successful in 45s
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:
@@ -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,)
|
||||
|
||||
Reference in New Issue
Block a user