Add GraphQL endpoint for code coverage group activity
Ref: #263478 (closed)
What does this MR do?
This MR exposes our code coverage data at the group level. This features is for GitLab Premium.
It includes the following items:
-
Adds new CodeCoverageSummary
type -
Exposes code_coverage_summaries
to GroupType
Why are we doing this?
This new feature allows us to build our overall coverage activity at the group level.
We decided to return a collection of CodeCoverageActivity
as this will help us to build the foundation.
This way, the backend will be ready to be consumed for our new feature: The coverage graph
The frontend will request the code coverage activity for the last 30 days and we will return all the necessary data points to draw our graph.
Example query
GraphQL request | Response |
---|---|
|
|
Query Plan
- cold cache:
1.440 s
- warm cache:
4.407 ms
Query:
SELECT
AVG(cast(data ->> 'coverage' AS float)),
COUNT(*),
COUNT(DISTINCT ci_daily_build_group_report_results.project_id),
"ci_daily_build_group_report_results"."date"
FROM
"ci_daily_build_group_report_results"
LEFT OUTER JOIN "projects" ON "projects"."id" = "ci_daily_build_group_report_results"."project_id"
WHERE
"ci_daily_build_group_report_results"."project_id" IN (
SELECT id
FROM projects
WHERE namespace_id = 9970)
AND ((data -> 'coverage') IS NOT NULL)
AND "ci_daily_build_group_report_results"."default_branch" = TRUE
AND "ci_daily_build_group_report_results"."date" BETWEEN '2020-09-28' AND '2020-10-28'
GROUP BY
"ci_daily_build_group_report_results"."date";
https://explain.depesz.com/s/KoNY
Query plan:Aggregate (cost=567.75..567.79 rows=1 width=28) (actual time=2.979..2.981 rows=1 loops=1)
Group Key: ci_daily_build_group_report_results.date
Buffers: shared hit=2338
-> Sort (cost=567.75..567.76 rows=1 width=42) (actual time=2.929..2.931 rows=10 loops=1)
Sort Key: ci_daily_build_group_report_results.date
Sort Method: quicksort Memory: 25kB
Buffers: shared hit=2338
-> Merge Join (cost=0.72..567.74 rows=1 width=42) (actual time=0.089..2.919 rows=10 loops=1)
Merge Cond: (ci_daily_build_group_report_results.project_id = projects.id)
Buffers: shared hit=2338
-> Index Scan using index_ci_daily_build_group_report_results_on_project_and_date on public.ci_daily_build_group_report_results (cost=0.28..547.38 rows=336 width=42) (actual time=0.047..2.406 rows=2365 loops=1)
Index Cond: ((ci_daily_build_group_report_results.date >= '2020-09-28'::date) AND (ci_daily_build_group_report_results.date <= '2020-10-28'::date))
Buffers: shared hit=2074
-> Index Only Scan using index_projects_on_namespace_id_and_id on public.projects (cost=0.43..18.59 rows=371 width=4) (actual time=0.037..0.201 rows=250 loops=1)
Index Cond: (projects.namespace_id = 9970)
Heap Fetches: 31
Buffers: shared hit=264
Cold cache:
Time: 1.440 s
- planning: 1.374 ms
- execution: 1.438 s
- I/O read: 876.953 ms
- I/O write: 0.000 ms
Shared buffers:
- hits: 1873 (~14.60 MiB) from the buffer pool
- reads: 631 (~4.90 MiB) from the OS file cache, including disk I/O
- dirtied: 582 (~4.50 MiB)
- writes: 0
Warm cache:
Time: 4.407 ms
- planning: 1.341 ms
- execution: 3.066 ms
- I/O read: 0.000 ms
- I/O write: 0.000 ms
Shared buffers:
- hits: 2338 (~18.30 MiB) from the buffer pool
- reads: 0 from the OS file cache, including disk I/O
- dirtied: 0
- writes: 0
How the feature looks like?
You can visualize how this feature looks like on the mocks.
Screenshots
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