Skip to content

Fix group code coverage for default branch

Max Orefice requested to merge mo-fix-group-coverage-for-default-branch into master

Ref: #270102 (closed)

What does this MR do?

This MR fixes a ~bug where the group code coverage is empty if the default branch is different than master.

Why are we doing this?

This MR makes our ref_path argument optional so we are now defaulting the group code coverage to the default branch which could be anything.

Database review

Here the new SQL query used for this query.

The goal for this MR is to fix our ~bug.

We will follow up with another MR to extends our finder with more capacity such as using an existing index to speed up this query.

Click to expand

Query 1: ref_path = 'refs/heads/master' (unchanged)

SELECT * FROM ci_daily_build_group_report_results
WHERE project_id = 278964
AND date BETWEEN '2020-12-09' AND '2020-12-10'
AND ref_path = 'refs/heads/master'

Plan:

 Index Scan using index_daily_build_group_report_results_unique_columns on public.ci_daily_build_group_report_results  (cost=0.56..231.96 rows=150 width=102) (actual time=0.784..1.317 rows=6 loops=1)
   Index Cond: ((ci_daily_build_group_report_results.project_id = 278964) AND (ci_daily_build_group_report_results.ref_path = 'refs/heads/master'::text) AND (ci_daily_build_group_report_results.date >= '2020-12-09'::date) AND (ci_daily_build_group_report_results.date <= '2020-12-10'::date))
   Buffers: shared hit=4 read=8 dirtied=5
   I/O Timings: read=0.783

Cold cache:

Time: 1.641 ms  
  - planning: 0.298 ms  
  - execution: 1.343 ms  
    - I/O read: 0.783 ms  
    - I/O write: 0.000 ms  
  
Shared buffers:  
  - hits: 4 (~32.00 KiB) from the buffer pool  
  - reads: 8 (~64.00 KiB) from the OS file cache, including disk I/O  
  - dirtied: 5 (~40.00 KiB)  
  - writes: 0  

Query 2: default_branch = TRUE (new)

SELECT * FROM ci_daily_build_group_report_results
WHERE project_id = 278964
AND date BETWEEN '2020-12-09' AND '2020-12-10'
AND default_branch = TRUE;

Query plan:

 Index Scan using index_daily_build_group_report_results_unique_columns on public.ci_daily_build_group_report_results  (cost=0.56..3160.37 rows=29 width=102) (actual time=1138.846..1427.305 rows=6 loops=1)
   Index Cond: ((ci_daily_build_group_report_results.project_id = 278964) AND (ci_daily_build_group_report_results.date >= '2020-12-09'::date) AND (ci_daily_build_group_report_results.date <= '2020-12-10'::date))
   Filter: ci_daily_build_group_report_results.default_branch
   Rows Removed by Filter: 788
   Buffers: shared hit=109 read=1482 dirtied=223
   I/O Timings: read=1033.539

Cold cache:

Time: 1.306 s  
  - planning: 0.289 ms  
  - execution: 1.305 s  
    - I/O read: 1.004 s  
    - I/O write: 0.000 ms  
  
Shared buffers:  
  - hits: 112 (~896.00 KiB) from the buffer pool  
  - reads: 1474 (~11.50 MiB) from the OS file cache, including disk I/O  
  - dirtied: 217 (~1.70 MiB)  
  - writes: 0  
  

Warm cache:

Time: 12.133 ms  
  - planning: 0.808 ms  
  - execution: 11.325 ms  
    - I/O read: 0.000 ms  
    - I/O write: 0.000 ms  
  
Shared buffers:  
  - hits: 1543 (~12.10 MiB) from the buffer pool  
  - reads: 0 from the OS file cache, including disk I/O  
  - dirtied: 0  
  - writes: 0  

Screenshots (strongly suggested)

Repositories_Analytics___GitLab.org___GitLab_2020-12-10_10-18-13

You can see how the feature looks like on this url.

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 Toon Claes

Merge request reports