lib/pact_broker/matrix/row.rb in pact_broker-2.24.0 vs lib/pact_broker/matrix/row.rb in pact_broker-2.25.0

- old
+ new

@@ -6,11 +6,11 @@ require 'pact_broker/verifications/latest_verification_for_consumer_and_provider' module PactBroker module Matrix - class Row < Sequel::Model(:materialized_matrix) + class Row < Sequel::Model(:matrix) # Used when using table_print to output query results TP_COLS = [ :consumer_version_number, :pact_revision_number, :provider_version_number, :verification_number] associate(:one_to_many, :latest_triggered_webhooks, :class => "PactBroker::Webhooks::LatestTriggeredWebhook", primary_key: :pact_publication_id, key: :pact_publication_id) @@ -24,36 +24,10 @@ dataset_module do include PactBroker::Repositories::Helpers include PactBroker::Logging - def refresh ids - logger.debug("Refreshing #{model.table_name} for #{ids}") - - db = model.db - table_name = model.table_name - - if ids[:pacticipant_id] - db.transaction do - db[table_name].where(consumer_id: ids[:pacticipant_id]).or(provider_id: ids[:pacticipant_id]).delete - new_rows = db[source_view_name].where(consumer_id: ids[:pacticipant_id]).or(provider_id: ids[:pacticipant_id]).distinct - db[table_name].insert(new_rows) - end - elsif ids.any? - accepted_columns = [:consumer_id, :consumer_name, :provider_id, :provider_name] - criteria = ids.reject{ |k, v| !accepted_columns.include?(k) } - db.transaction do - db[table_name].where(criteria).delete - db[table_name].insert(db[source_view_name].where(criteria)) - end - end - end - - def source_view_name - model.table_name.to_s.gsub('materialized_', '').to_sym - end - def matching_selectors selectors if selectors.size == 1 where_consumer_or_provider_is(selectors.first) else where_consumer_and_provider_in(selectors) @@ -225,5 +199,28 @@ (obj.class == model) && (obj.values == values) end end end end + +# Table: matrix +# Columns: +# consumer_id | integer | +# consumer_name | text | +# consumer_version_id | integer | +# consumer_version_number | text | +# consumer_version_order | integer | +# pact_publication_id | integer | +# pact_version_id | integer | +# pact_version_sha | text | +# pact_revision_number | integer | +# pact_created_at | timestamp without time zone | +# provider_id | integer | +# provider_name | text | +# provider_version_id | integer | +# provider_version_number | text | +# provider_version_order | integer | +# verification_id | integer | +# success | boolean | +# verification_number | integer | +# verification_executed_at | timestamp without time zone | +# verification_build_url | text |