Skip to content

Add athlete audit ingestion and history APIs under /api/v1#10

Draft
Copilot wants to merge 13 commits into
mainfrom
copilot/implement-athlete-logging-endpoints-again
Draft

Add athlete audit ingestion and history APIs under /api/v1#10
Copilot wants to merge 13 commits into
mainfrom
copilot/implement-athlete-logging-endpoints-again

Conversation

Copilot AI commented May 18, 2026

Copy link
Copy Markdown

This PR implements backend support for daily athlete audit submission and historical retrieval. It introduces a write path for audit metrics with strict input validation and a read path for athlete-specific audit history ordered newest-first.

  • API surface

    • Added POST /api/v1/audit to accept athlete daily audit payloads.
    • Added GET /api/v1/athletes/{id}/history to return all stored audit logs for an athlete, sorted by most recent date/time.
  • Validation and error semantics

    • Added schema-level validation for:
      • date format (YYYY-MM-DD)
      • non-empty scores
      • score bounds (1..10, inclusive)
    • Normalized invalid payload handling to 400 Bad Request.
    • Returns 404 Not Found when athlete ID does not exist for both endpoints.
  • Persistence and retrieval

    • Added audit log storage in backend data layer (audit_logs.json).
    • Centralized created_at generation in persistence helper to keep timestamping consistent.
    • Added robust history parsing that skips malformed persisted rows instead of failing whole responses.
  • Docs

    • Updated README API endpoint table with the two new /api/v1 endpoints.
# main.py (new endpoint shape)
@app.post("/api/v1/audit")
async def create_audit_log(req: AuditRequest):
    if not get_athlete(req.athlete_id):
        raise HTTPException(status_code=404, detail=f"Athlete {req.athlete_id} not found")
    audit_entry = add_audit_log({
        "athlete_id": req.athlete_id,
        "date": req.date,
        "scores": req.scores,
    })
    return {"status": "created", "audit": audit_entry}

Copilot AI and others added 12 commits May 18, 2026 18:30
Copilot AI changed the title [WIP] Implement REST API endpoints for athlete logging and retrieval Add athlete audit ingestion and history APIs under /api/v1 May 18, 2026
Copilot AI requested a review from unoursmarin May 18, 2026 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement REST API endpoints for Athlete Logging and Retrieval

2 participants