Simplify support for pagination for group
What does this MR do and why?
Simplify support for pagination for group level dependency list.
EE: true Changelog: changed
Related issue: #408855 (closed)
Query changes
From
SELECT "sbom_occurrences".* FROM "sbom_occurrences" WHERE "sbom_occurrences"."project_id" IN (SELECT "projects"."id" FROM "projects" WHERE "projects"."namespace_id" IN (SELECT namespaces.traversal_ids[array_length(namespaces.traversal_ids, 1)] AS id FROM "namespaces" WHERE "namespaces"."type" = 'Group' AND (traversal_ids @> ('{5022335}')))) ORDER BY "sbom_occurrences"."id" ASC LIMIT 25 OFFSET 0
offset_pagination)
To (Based onSELECT COUNT(*) FROM (SELECT 1 AS one FROM "sbom_occurrences" WHERE "sbom_occurrences"."project_id" IN (SELECT "projects"."id" FROM "projects" WHERE "projects"."namespace_id" IN (SELECT namespaces.traversal_ids[array_length(namespaces.traversal_ids, 1)] AS id FROM "namespaces" WHERE "namespaces"."type" = 'Group' AND (traversal_ids @> ('{5022335}')))) LIMIT 10001) subquery_for_count
SELECT "sbom_occurrences".* FROM "sbom_occurrences" WHERE "sbom_occurrences"."project_id" IN (SELECT "projects"."id" FROM "projects" WHERE "projects"."namespace_id" IN (SELECT namespaces.traversal_ids[array_length(namespaces.traversal_ids, 1)] AS id FROM "namespaces" WHERE "namespaces"."type" = 'Group' AND (traversal_ids @> ('{5022335}')))) ORDER BY "sbom_occurrences"."id" ASC LIMIT 20 OFFSET 0
How to set up and validate locally
- Fetch the content of both branches:
add_support_for_pagination_for_group_level_dependency_list
. - Turn on the feature flag to make
Dependency list
appear in groups:
echo "Feature.enable(:group_level_dependencies)" | rails c
- Create a project under a group with the following content:
-
.gitlab-ci.yml
:
include:
- template: Security/Dependency-Scanning.gitlab-ci.yml
-
Gemfile.lock
: with this content
- Run a pipeline for the default branch
- Query against the json endpoint similar to the following format:
http://gdk.test:3000/groups/top-level-group/-/dependencies.json
- The following headers should be available as part of the response:
- Link:
<http://gdk.test:3000/groups/top-level-group/-/dependencies.json?page=2&per_page=20>; rel="next", <http://gdk.test:3000/groups/top-level-group/-/dependencies.json?page=1&per_page=20>; rel="first", <http://gdk.test:3000/groups/top-level-group/-/dependencies.json?page=93&per_page=20>; rel="last"
- X-Next-Page: 2
- X-Page: 1
- X-Per-Page: 20
- X-Prev-Page:
- X-Total: 1855
- X-Total-Pages: 93
**Note that the values might change depending on the data being generated.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Zamir Martins