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:
parent
fdab4a5dac
commit
e7e3c97102
2 changed files with 10 additions and 8 deletions
|
|
@ -61,7 +61,9 @@ async def paginate_with_user_email(
|
|||
return records, total, calculate_total_pages(total, per_page)
|
||||
|
||||
|
||||
def _map_counter_record(record: CounterRecord, email: str) -> CounterRecordResponse:
|
||||
def _to_counter_record_response(
|
||||
record: CounterRecord, email: str
|
||||
) -> CounterRecordResponse:
|
||||
return CounterRecordResponse(
|
||||
id=record.id,
|
||||
user_email=email,
|
||||
|
|
@ -71,7 +73,7 @@ def _map_counter_record(record: CounterRecord, email: str) -> CounterRecordRespo
|
|||
)
|
||||
|
||||
|
||||
def _map_sum_record(record: SumRecord, email: str) -> SumRecordResponse:
|
||||
def _to_sum_record_response(record: SumRecord, email: str) -> SumRecordResponse:
|
||||
return SumRecordResponse(
|
||||
id=record.id,
|
||||
user_email=email,
|
||||
|
|
@ -91,7 +93,7 @@ async def get_counter_records(
|
|||
) -> PaginatedCounterRecords:
|
||||
"""Get paginated counter action records."""
|
||||
records, total, _ = await paginate_with_user_email(
|
||||
db, CounterRecord, page, per_page, _map_counter_record
|
||||
db, CounterRecord, page, per_page, _to_counter_record_response
|
||||
)
|
||||
return create_paginated_response(records, total, page, per_page)
|
||||
|
||||
|
|
@ -105,7 +107,7 @@ async def get_sum_records(
|
|||
) -> PaginatedSumRecords:
|
||||
"""Get paginated sum action records."""
|
||||
records, total, _ = await paginate_with_user_email(
|
||||
db, SumRecord, page, per_page, _map_sum_record
|
||||
db, SumRecord, page, per_page, _to_sum_record_response
|
||||
)
|
||||
return create_paginated_response(records, total, page, per_page)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue