Allow group projects to be queried by code coverage with GraphQL
Ref: #296665 (closed)
What does this MR do?
This MR allows to query group projects by code coverage with our GraphQL API.
It includes the following items:
-
New scope to query group projects with code coverage -
Add new argument ( hasCodeCoverage: Boolean
) to our group projects graphql endpoint
Why are we doing this?
We are working to improve our analytic page aggregating our code coverage data at the group level.
We are currently displaying all projects in our dropdown projects as you can see below
After this MR, we will be able to display only projects having a code coverage data in our project's dropdown for a given group.
Screenshots
GraphQL request | Response |
---|---|
|
|
This implementation is similar to our existing one filtering group projects with vulnerabilities:
Database review
Query
SELECT
projects.*
FROM
projects
INNER JOIN ci_daily_build_group_report_results ON ci_daily_build_group_report_results.project_id = projects.id
WHERE
projects.namespace_id = 22
AND ((data -> 'coverage') IS NOT NULL)
AND ci_daily_build_group_report_results.default_branch = TRUE
GROUP BY
projects.id
Execution plan
Group (cost=0.86..1609.87 rows=8 width=18) (actual time=12.469..760.310 rows=16 loops=1)
Group Key: projects.id
Buffers: shared hit=624 read=539 dirtied=49
I/O Timings: read=716.746
-> Nested Loop (cost=0.86..1609.85 rows=8 width=18) (actual time=12.466..759.816 rows=2493 loops=1)
Buffers: shared hit=624 read=539 dirtied=49
I/O Timings: read=716.746
-> Index Scan using index_projects_on_namespace_id_and_id on public.projects (cost=0.44..525.47 rows=356 width=18) (actual time=7.812..471.048 rows=260 loops=1)
Index Cond: (projects.namespace_id = 9970)
Buffers: shared hit=4 read=262 dirtied=6
I/O Timings: read=467.533
-> Index Only Scan using index_ci_daily_build_group_report_results_on_project_and_date on public.ci_daily_build_group_report_results (cost=0.42..2.89 rows=16 width=8) (actual time=0.761..1.104 rows=10 loops=260)
Index Cond: (ci_daily_build_group_report_results.project_id = projects.id)
Heap Fetches: 170
Buffers: shared hit=620 read=277 dirtied=43
I/O Timings: read=249.213
Cold cache
Time: 766.079 ms
- planning: 5.660 ms
- execution: 760.419 ms (estimated* for prod: 0.038...0.760 s)
- I/O read: 716.746 ms
- I/O write: N/A
Shared buffers:
- hits: 624 (~4.90 MiB) from the buffer pool
- reads: 539 (~4.20 MiB) from the OS file cache, including disk I/O
- dirtied: 49 (~392.00 KiB)
- writes: 0
Warm cache
Time: 4.761 ms
- planning: 1.067 ms
- execution: 3.694 ms
- I/O read: N/A
- I/O write: N/A
Shared buffers:
- hits: 1134 (~8.90 MiB) from the buffer pool
- reads: 0 from the OS file cache, including disk I/O
- dirtied: 0
- writes: 0
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 Max Orefice