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
+4 -10
View File
@@ -23,7 +23,7 @@ from watchdog.observers import Observer
from exif_parser import ExifError, parse_image
from ocr import read_bib
from passage_log import log_passage
from profile_db import get_athlete_by_bib, init_db
from profile_db import get_or_create_athlete, init_db
logger = logging.getLogger(__name__)
@@ -98,11 +98,7 @@ async def process_image(path: Path) -> None:
await init_db(db)
if bib_number and not needs_review:
athlete = await get_athlete_by_bib(db, bib_number)
if athlete:
profile_id = athlete["profile_id"]
else:
logger.debug("Ukjent startnummer: %s", bib_number)
profile_id = await get_or_create_athlete(db, bib_number)
await log_passage(
db,
@@ -141,7 +137,7 @@ async def process_image_with_override(
EXIF-tid brukes hvis tilgjengelig, ellers nåværende tidspunkt.
"""
from datetime import datetime, timezone
from profile_db import get_athlete_by_bib
from profile_db import get_or_create_athlete as _get_or_create
logger.info("Web-opplasting: %s → stasjon=%s", path.name, station_name)
@@ -165,9 +161,7 @@ async def process_image_with_override(
profile_id = None
if ocr.digits and not needs_review:
athlete = await get_athlete_by_bib(db, ocr.digits)
if athlete:
profile_id = athlete["profile_id"]
profile_id = await _get_or_create(db, ocr.digits)
await log_passage(
db,