Class: GitlabQuality::TestTooling::CodeCoverage::ClickHouse::CategoryOwnersTable
- Inherits:
-
Table
- Object
- Table
- GitlabQuality::TestTooling::CodeCoverage::ClickHouse::CategoryOwnersTable
- Defined in:
- lib/gitlab_quality/test_tooling/code_coverage/click_house/category_owners_table.rb
Constant Summary collapse
- TABLE_NAME =
"category_owners"- MissingMappingError =
Class.new(StandardError)
- KNOWN_UNOWNED =
%w[shared not_owned tooling].freeze
- LATEST_RECORDS_QUERY =
SQL query to get the latest ownership record for each unique category+ownership combination Partitions by the full composite key to handle cases where a category has multiple ownerships
<<~SQL SELECT category, group, stage, section FROM ( SELECT category, group, stage, section, ROW_NUMBER() OVER (PARTITION BY category, group, stage, section ORDER BY timestamp DESC) as rn FROM %{table_name} ) WHERE rn = 1 SQL
Constants inherited from Table
Instance Method Summary collapse
-
#owner_records ⇒ Hash
Raw category owner data.
-
#owners(feature_category_name) ⇒ Hash
Owners of particular feature category as group, stage and section.
-
#push(data) ⇒ Object
Insert only new category ownership records that don’t already exist This avoids needing TRUNCATE permission.
Methods inherited from Table
Constructor Details
This class inherits a constructor from GitlabQuality::TestTooling::CodeCoverage::ClickHouse::Table
Instance Method Details
#owner_records ⇒ Hash
Raw category owner data
67 68 69 |
# File 'lib/gitlab_quality/test_tooling/code_coverage/click_house/category_owners_table.rb', line 67 def owner_records records.deep_dup end |
#owners(feature_category_name) ⇒ Hash
Owners of particular feature category as group, stage and section
51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/gitlab_quality/test_tooling/code_coverage/click_house/category_owners_table.rb', line 51 def owners(feature_category_name) if KNOWN_UNOWNED.include?(feature_category_name) logger.info( "#{LOG_PREFIX} #{feature_category_name} is a known feature category without owner..." ) return {} end records.fetch(feature_category_name) rescue KeyError raise(MissingMappingError, "Feature category '#{feature_category_name}' not found in table '#{table_name}'") end |
#push(data) ⇒ Object
Insert only new category ownership records that don’t already exist This avoids needing TRUNCATE permission
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/gitlab_quality/test_tooling/code_coverage/click_house/category_owners_table.rb', line 32 def push(data) return logger.warn("#{LOG_PREFIX} No data found, skipping insert!") if data.empty? sanitized_data = sanitize_and_filter_data(data) return if sanitized_data.empty? new_records = filter_new_records(sanitized_data) return if new_records.empty? insert_new_records(new_records, sanitized_data.size) rescue StandardError => e logger.error("#{LOG_PREFIX} Error occurred while pushing data to #{full_table_name}: #{e.}") raise end |