Skip to content

Draft: Mo add group coverage data finder [RUN ALL RSPEC] [RUN AS-IF-FOSS]

Max Orefice requested to merge mo-add-group-coverage-data-finder into master

Ref: #293825 (closed)

This feature will be behind a feature flag called coverage_data_new_finder

This is Step #3 to refactor our daily coverage data finder.

What does this MR do?

This MR creates a new finder which refactors how we fetch our daily coverage data at the group level.

It includes the following items:

  • Extend EE finder with group filtering
  • Hook up new finder in controller

Why are we doing this?

As part of our effort to reduce our ~"technical debt", we are refactoring our daily coverage finder

This finder is used at 2 different places, so we decided to introduce a feature flag to mitigate the risk of ~performance degradation.

  1. Aggregate daily coverage by project - https://gitlab.com/gitlab-org/gitlab/-/graphs/master/charts
  2. Aggregate daily coverage by group - https://gitlab.com/groups/gitlab-org/-/analytics/repository_analytics

We recently added a new group_id column to fetch our data by group (!53494 (merged)) which is now used in this MR.

Database review

SQL Query

SELECT
    ci_daily_build_group_report_results.*
FROM
    ci_daily_build_group_report_results
WHERE
    ci_daily_build_group_report_results.group_id = 22
    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 '2021-01-12'
    AND '2021-02-12'
ORDER BY
    ci_daily_build_group_report_results.date DESC,
    ci_daily_build_group_report_results.group_name ASC

Query plan

 Sort  (cost=3.47..3.47 rows=1 width=110) (actual time=2.313..2.314 rows=0 loops=1)
   Sort Key: ci_daily_build_group_report_results.date DESC, ci_daily_build_group_report_results.group_name
   Sort Method: quicksort  Memory: 25kB
   Buffers: shared hit=9 read=3
   I/O Timings: read=2.171
   ->  Index Scan using index_ci_daily_build_group_report_results_on_group_id on public.ci_daily_build_group_report_results  (cost=0.43..3.46 rows=1 width=110) (actual time=2.261..2.261 rows=0 loops=1)
         Index Cond: (ci_daily_build_group_report_results.group_id = 22)
         Filter: (ci_daily_build_group_report_results.default_branch AND ((ci_daily_build_group_report_results.data -> 'coverage'::text) IS NOT NULL) AND (ci_daily_build_group_report_results.date >= '2021-01-12'::date) AND (ci_daily_build_group_report_results.date <= '2021-02-12'::date))
         Rows Removed by Filter: 0
         Buffers: shared hit=3 read=3
         I/O Timings: read=2.171

Cold cache

Time: 3.683 ms
  - planning: 1.318 ms
  - execution: 2.365 ms
    - I/O read: 2.171 ms
    - I/O write: N/A

Shared buffers:
  - hits: 9 (~72.00 KiB) from the buffer pool
  - reads: 3 (~24.00 KiB) from the OS file cache, including disk I/O
  - dirtied: 0
  - writes: 0

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

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

Merge request reports