feature: content app json listing - #7996
Conversation
There was a problem hiding this comment.
Re-review (v2)
Both findings from the initial review have been addressed:
Resolved: list_directory_flat now uses DB-level pagination
Pagination is pushed to the database with path_qs[offset:offset+limit] and .count() for the total. Only the page's items are loaded into memory. The _content_relationships() date lookup is now filtered with .filter(content_id__in=content_ids). A new test asserts that LIMIT appears in the captured SQL. This addresses the O(N) memory concern.
Resolved: Cache keys now use normalized pagination params
make_key now computes a normalized {limit}:{offset} string for JSON requests (via the shared json_listing_pagination() function) and omits the query component entirely for HTML requests. Junk query params are ignored for both formats. Verified with our proving test — all 3 cache pollution scenarios now pass.
Remaining: CI lint failure
The v2 push has a lint failure on import sorting (ruff check --fix && ruff format should fix it). Tests are gated on lint so haven't run yet in CI.
fcef9d3 to
0d8cfb3
Compare
|
@dkliban thanks for the review!
|
0d8cfb3 to
c673d4f
Compare
Serve a paginated JSON directory listing when Accept prefers application/json. Plugins can override Distribution.content_handler_json. Listing pagination is applied in the database; cache keys use only normalized JSON limit/offset. ref pulp#7887 Assisted-By: Cursor
c673d4f to
d0def8c
Compare
📜 Checklist
Description
This PR:
Acceptprefers JSONDistribution.content_handler_json()so plugins can customize that JSONCloses #7887