Add package_name as option to packages API
What does this MR do?
Adds the package_name
parameter to the :id/packages
API endpoint. This allows the list of packages returned from this API call to be filtered by package_name
.
Opens up frontend work in #197920 (closed).
Screenshots
No visual changes.
Database
Query:
SELECT
"packages_packages".*
FROM
"packages_packages"
WHERE
"packages_packages"."project_id" = 9
AND "packages_packages"."name" ILIKE '%Nuget%'
ORDER BY
created_at ASC
LIMIT 20 OFFSET 0
Explain (from chatops):
Limit (cost=56.91..56.92 rows=1 width=80) (actual time=1.596..1.596 rows=0 loops=1)
Buffers: shared hit=12 read=29
I/O Timings: read=0.236
-> Sort (cost=56.91..56.92 rows=1 width=80) (actual time=1.595..1.595 rows=0 loops=1)
Sort Key: created_at
Sort Method: quicksort Memory: 25kB
Buffers: shared hit=12 read=29
I/O Timings: read=0.236
-> Bitmap Heap Scan on packages_packages (cost=55.39..56.90 rows=1 width=80) (actual time=1.579..1.579 rows=0 loops=1)
Recheck Cond: ((project_id = 15400614) AND ((name)::text ~~* '%Nuget%'::text))
Buffers: shared hit=9 read=29
I/O Timings: read=0.236
-> BitmapAnd (cost=55.39..55.39 rows=1 width=0) (actual time=1.578..1.578 rows=0 loops=1)
Buffers: shared hit=9 read=29
I/O Timings: read=0.236
-> Bitmap Index Scan on index_packages_packages_on_project_id_and_package_type (cost=0.00..2.62 rows=110 width=0) (actual time=0.178..0.178 rows=109 loops=1)
Index Cond: (project_id = 15400614)
Buffers: shared hit=1 read=2
I/O Timings: read=0.023
-> Bitmap Index Scan on index_packages_packages_on_name_trigram (cost=0.00..52.52 rows=3 width=0) (actual time=1.391..1.391 rows=19 loops=1)
Index Cond: ((name)::text ~~* '%Nuget%'::text)
Buffers: shared hit=8 read=27
I/O Timings: read=0.213
Planning time: 5.265 ms
Execution time: 1.700 ms
Visual: https://explain.depesz.com/s/3ies
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