Class: GitlabQuality::TestTooling::CodeCoverage::TestFileMappingData
- Inherits:
-
Object
- Object
- GitlabQuality::TestTooling::CodeCoverage::TestFileMappingData
- Defined in:
- lib/gitlab_quality/test_tooling/code_coverage/test_file_mapping_data.rb
Instance Method Summary collapse
-
#as_db_table ⇒ Array<Hash<Symbol, String>>
Rows for shared.test_file_mappings, one per test-and-source pair.
-
#initialize(test_to_sources, tests_to_categories: {}) ⇒ TestFileMappingData
constructor
A new instance of TestFileMappingData.
Constructor Details
#initialize(test_to_sources, tests_to_categories: {}) ⇒ TestFileMappingData
Returns a new instance of TestFileMappingData.
11 12 13 14 |
# File 'lib/gitlab_quality/test_tooling/code_coverage/test_file_mapping_data.rb', line 11 def initialize(test_to_sources, tests_to_categories: {}) @test_to_sources = test_to_sources @tests_to_categories = tests_to_categories end |
Instance Method Details
#as_db_table ⇒ Array<Hash<Symbol, String>>
Rows for shared.test_file_mappings, one per test-and-source pair.
Carries no group, stage or section on purpose. Those describe the category rather than the mapping and change whenever stages.yml is reorganised, so storing them on every mapping multiplies rows for no gain.
Readers resolve ownership from shared.category_owners through category. That table keeps every historical row, up to 57 for one category, so a plain join fans out; dedupe it with ORDER BY category, timestamp DESC LIMIT 1 BY category.
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/gitlab_quality/test_tooling/code_coverage/test_file_mapping_data.rb', line 33 def as_db_table @test_to_sources.flat_map do |test_file, source_files| category = @tests_to_categories[test_file]&.first || '' source_files.map do |source_file| { test_file: test_file, source_file: source_file, category: category } end end end |