Add package_name param to group packages API
What does this MR do?
Issue: #216451 (closed)
Adds the package_name
parameter to the :id/packages
API endpoint at the group level. This allows the list of packages returned from this API call to be filtered by package_name
.
Screenshots
No visual changes.
Database
Query:
SELECT
"packages_packages".*
FROM
"packages_packages"
WHERE
"packages_packages"."project_id" IN (17842971, 17719928, 17545989, 17471714, 17421565, 17130955, 17120503, 16494314, 15875037)
AND ("packages_packages"."package_type" != 4
OR "packages_packages"."name" != 'NuGet.Temporary.Package')
AND "packages_packages"."version" IS NOT NULL
AND "packages_packages"."name" ILIKE '%pypipackage%'
ORDER BY
created_at DESC
LIMIT 20 OFFSET 0;
Explain (from chatops):
Limit (cost=86.45..86.45 rows=1 width=83) (actual time=8.567..8.567 rows=1 loops=1)
Buffers: shared hit=34 read=31
I/O Timings: read=6.227
-> Sort (cost=86.45..86.45 rows=1 width=83) (actual time=8.567..8.567 rows=1 loops=1)
Sort Key: created_at DESC
Sort Method: quicksort Memory: 25kB
Buffers: shared hit=34 read=31
I/O Timings: read=6.227
-> Bitmap Heap Scan on packages_packages (cost=76.54..86.44 rows=1 width=83) (actual time=8.487..8.546 rows=1 loops=1)
Recheck Cond: ((name)::text ~~* '%pypipackage%'::text)
Filter: ((version IS NOT NULL) AND ((package_type <> 4) OR ((name)::text <> 'NuGet.Temporary.Package'::text)) AND (project_id = ANY ('{17842971,17719928,17545989,17471714,17421565,17130955,17120503,16494314,15875037}'::integer[])))
Rows Removed by Filter: 7
Heap Blocks: exact=8
Buffers: shared hit=31 read=31
I/O Timings: read=6.227
-> Bitmap Index Scan on index_packages_packages_on_name_trigram (cost=0.00..76.54 rows=6 width=0) (actual time=8.197..8.197 rows=8 loops=1)
Index Cond: ((name)::text ~~* '%pypipackage%'::text)
Buffers: shared hit=26 read=28
I/O Timings: read=6.196
Planning time: 5.741 ms
Execution time: 8.688 ms
Visual: https://explain.depesz.com/s/39JX
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. - [-] Tested in all supported browsers
- [-] Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
- [-] Label as security and @ mention
@gitlab-com/gl-security/appsec
- [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
- [-] Security reports checked/validated by a reviewer from the AppSec team
Edited by Nick Kipling