Sprint 2 api-v2 public endpoints and performance follow-ups#713
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds new v2 API endpoints for characters, creators, groups, and universes, and optimizes existing issue and series endpoints with specialized pagination and database indexing. The review feedback recommends enhancing robustness against non-numeric legacy data in integer casts, using .get() instead of .first() for unique lookups to ensure data integrity, and utilizing queryset intersections for more efficient issue filtering.
| 'created__lte', | ||
| ) | ||
|
|
||
| def filter_language(self, queryset, name, value): |
There was a problem hiding this comment.
Can this be made generic ? And used for groups and series ?
There was a problem hiding this comment.
Hmm, why the filter to id and not use the code ?
There was a problem hiding this comment.
The public filter still takes the code, so ?language=en stays the API contract. Internally it resolves that once to language_id and filters on the FK id so the list queries avoid the stddata_language join and can use the language-shaped indexes. I added coverage for the SQL shape on all three filters too.
| ) | ||
| language = django_filters.CharFilter(method='filter_language') | ||
| universe = django_filters.NumberFilter(field_name='universe_id') | ||
| modified__gt = django_filters.IsoDateTimeFilter( |
There was a problem hiding this comment.
the modified and created are the same always ?
Can we make a base class with these and make the specific filters for an object be based on that?
There was a problem hiding this comment.
Good call. I moved the standard created/modified range filters into a shared TimestampFilterSet and added a shared field tuple for the Meta.fields lists.
The resource filtersets now only declare their own filters and inherit the common timestamp ones, so the next endpoints can reuse the same base instead of copying that block around.
Summary
This PR completes the Sprint 2 public
api-v2surface and includes the follow-up performance work needed to keep the new endpoints usable against production-scale data.Included in this branch:
seriesbrowse payloads and add the v2 browse indexissues.on_sale_iso_weekuniversesendpointsgroupsendpointscharactersendpointscreatorsendpointscharacters,groups, andissuesVerification
Code-level verification:
ruff checkpassed on changed filesruff format --checkpassed on changed filespython manage.py checkpassed ingcd-django-docker-web-1Manual verification against the running production-copy DB:
200Representative perf improvements from the manual harness:
issues modified__gt=2025-01-01:2564.6ms -> 48.0msissues variant_only:798.0ms -> 85.5mscharacters list:213.5ms -> 48.2mscharacters language=en:181.1ms -> 77.9msgroups list:180.0ms -> 98.0ms