Repository navigation
perf(api): batch active finding IDs on the products list - #17055
Open
tayfunozgur13 wants to merge 1 commit into
Open
tayfunozgur13 wants to merge 1 commit into
tayfunozgur13 wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The products list still runs one query per product for
findings_list, even after the other relation-loading improvements in #16037. A page growing from one product to five therefore adds four queries, including for a regular member.Load active finding IDs in one query after authorization, filtering and pagination, and let
ProductSerializeruse those page-local lists. Only IDs and their product IDs are selected; findings are not materialized as model instances. Preserve the current finding ordering, active-only selection and complete response arrays. Detail and write responses retain the existing fallback.Batching applies only to the list action: delete previews also use this paginator, but contain rendered dictionaries rather than Product instances.
Related to #16727. This addresses the remaining per-product query growth. The separate proposal to cap or replace
findings_listremains open; large ID arrays still produce large responses.Test results
Added coverage for query growth as an administrator and a member, products without active findings, ID ordering across engagements, inactive findings, unchanged active false-positive behavior, authorization, filtering, pagination, empty pages and retrieve fallback. Strengthened the existing product regression to require zero query growth.
./run-unittest.sh --test-case 'unittests.test_api_product_prefetch unittests.test_rest_framework.ProductTest unittests.test_apiv2_list_query_scaling unittests.test_apiv2_prefetch_locations unittests.test_product_authorized_users_api_authz unittests.test_apiv2_server_error_logging'ruff check --config ruff.toml .passed with the pinned Ruff 0.16.10.docker compose exec -T uwsgi python manage.py checkpassed with existing development-environment warnings.docker compose exec -T uwsgi python manage.py makemigrations --check --dry-run: no changes detected.docker compose exec -T uwsgi python manage.py spectacular --fail-on-warnpassed.No migrations, dependencies or API contract changes.