Fix group code coverage for default branch
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.
Plan: Cold cache: Query plan: Cold cache: Warm cache: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' 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.783Time: 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; 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.539Time: 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
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)
You can see how the feature looks like on this url.
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
