refactor(backend): standardize model-to-response conversion naming

Issue #8: Inconsistent naming for model-to-response conversion functions.

Changes:
- Rename build_invite_response to _to_invite_response (invites.py)
- Rename _map_counter_record to _to_counter_record_response (audit.py)
- Rename _map_sum_record to _to_sum_record_response (audit.py)

All conversion functions now follow the _to_X_response pattern,
using underscore prefix for module-private functions.
This commit is contained in:
counterweight 2025-12-22 09:16:05 +01:00
parent fdab4a5dac
commit e7e3c97102
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C
2 changed files with 10 additions and 8 deletions

View file

@ -31,7 +31,7 @@ admin_router = APIRouter(prefix="/api/admin", tags=["admin"])
MAX_INVITE_COLLISION_RETRIES = 3
def build_invite_response(invite: Invite) -> InviteResponse:
def _to_invite_response(invite: Invite) -> InviteResponse:
"""Build an InviteResponse from an Invite with loaded relationships."""
return InviteResponse(
id=invite.id,
@ -150,7 +150,7 @@ async def create_invite(
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
detail="Failed to create invite",
)
return build_invite_response(invite)
return _to_invite_response(invite)
@admin_router.get("/invites", response_model=PaginatedInviteRecords)
@ -197,7 +197,7 @@ async def list_all_invites(
invites = result.scalars().all()
# Build responses using preloaded relationships
records = [build_invite_response(invite) for invite in invites]
records = [_to_invite_response(invite) for invite in invites]
return create_paginated_response(records, total, page, per_page)
@ -230,7 +230,7 @@ async def revoke_invite(
await db.commit()
await db.refresh(invite)
return build_invite_response(invite)
return _to_invite_response(invite)
# All routers from this module for easy registration