Class: GitlabQuality::TestTooling::CodeCoverage::ClickHouse::TestFileMappingsTable
- Inherits:
-
Table
- Object
- Table
- GitlabQuality::TestTooling::CodeCoverage::ClickHouse::TestFileMappingsTable
- Defined in:
- lib/gitlab_quality/test_tooling/code_coverage/click_house/test_file_mappings_table.rb
Constant Summary collapse
- TABLE_NAME =
"test_file_mappings"
Instance Method Summary collapse
-
#push(data) ⇒ nil
Override push to skip mappings already stored with the same values.
Methods inherited from Table
Constructor Details
This class inherits a constructor from GitlabQuality::TestTooling::CodeCoverage::ClickHouse::Table
Instance Method Details
#push(data) ⇒ nil
Override push to skip mappings already stored with the same values.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/gitlab_quality/test_tooling/code_coverage/click_house/test_file_mappings_table.rb', line 16 def push(data) # rubocop:disable Metrics/AbcSize return logger.warn("#{LOG_PREFIX} No data found, skipping ClickHouse export!") if data.empty? logger.debug("#{LOG_PREFIX} Starting data export to ClickHouse") @dropped_source_files = [] sanitized_data = sanitize(data) report_dropped_source_files(sanitized_data.size) return logger.warn("#{LOG_PREFIX} No valid data found after sanitization, skipping ClickHouse export!") if sanitized_data.empty? # Filter out records that already exist with identical values new_or_changed_records = filter_duplicates(sanitized_data) if new_or_changed_records.empty? logger.info("#{LOG_PREFIX} None of the #{sanitized_data.size} mappings need writing to #{full_table_name}, skipping insert") return end client.insert_json_data(table_name, new_or_changed_records) skipped_count = sanitized_data.size - new_or_changed_records.size logger.info("#{LOG_PREFIX} Successfully pushed #{new_or_changed_records.size} new/changed records " \ "to #{full_table_name} (#{skipped_count} not written)") rescue StandardError => e logger.error("#{LOG_PREFIX} Error occurred while pushing data to #{full_table_name}: #{e.message}") raise end |