class PactBroker::Integrations::Integration

The columns are explicitly specified for the Integration object so that the consumer_name and provider_name columns aren’t included in the model. Those columns exist in the integrations table because the integrations table used to be an integrations view based on the pact_publications table, and those columns existed in the view. When the view was migrated to be a table (in db/migrations/20211102_create_table_temp_integrations.rb and the following migrations) the columns had to be maintained for backwards compatiblity. They are not used by the current code, however.

Constants

INTEGRATION_COLUMNS
LATEST_PACT_EAGER_LOADER

When viewing the index, every latest_pact in the database will match at least one of the rows, so it makes sense to load the entire table and match each pact to the appropriate row. Update: now we have pagination, we should probably filter the pacts by consumer/provider id.

Public Class Methods

compare_by_last_action_date(a, b) click to toggle source
# File lib/pact_broker/integrations/integration.rb, line 102
def self.compare_by_last_action_date a, b
  if b.latest_pact_or_verification_publication_date && a.latest_pact_or_verification_publication_date
    b.latest_pact_or_verification_publication_date <=> a.latest_pact_or_verification_publication_date
  elsif b.latest_pact_or_verification_publication_date
    1
  elsif a.latest_pact_or_verification_publication_date
    -1
  else
    a <=> b
  end
end

Public Instance Methods

<=>(other) click to toggle source
# File lib/pact_broker/integrations/integration.rb, line 127
def <=>(other)
  [consumer_name.downcase, provider_name.downcase] <=> [other.consumer_name.downcase, other.provider_name.downcase]
end
consumer_name() click to toggle source
# File lib/pact_broker/integrations/integration.rb, line 131
def consumer_name
  consumer.name
end
filter_by_pacticipant(query_string) click to toggle source
# File lib/pact_broker/integrations/integration.rb, line 91
def filter_by_pacticipant(query_string)
  matching_pacticipants = PactBroker::Domain::Pacticipant.filter(:name, query_string)
  pacticipants_join = Sequel.|({ Sequel[:integrations][:consumer_id] => Sequel[:p][:id] }, { Sequel[:integrations][:provider_id] => Sequel[:p][:id] })
  join(matching_pacticipants, pacticipants_join, table_alias: :p)
end
including_pacticipant_id(pacticipant_id) click to toggle source
# File lib/pact_broker/integrations/integration.rb, line 97
def including_pacticipant_id(pacticipant_id)
  where(consumer_id: pacticipant_id).or(provider_id: pacticipant_id)
end
latest_pact_or_verification_publication_date() click to toggle source
# File lib/pact_broker/integrations/integration.rb, line 119
def latest_pact_or_verification_publication_date
  [latest_pact&.created_at, latest_verification_publication_date].compact.max
end
latest_verification_publication_date() click to toggle source
# File lib/pact_broker/integrations/integration.rb, line 123
def latest_verification_publication_date
  latest_verification&.execution_date
end
pacticipant_ids() click to toggle source
# File lib/pact_broker/integrations/integration.rb, line 139
def pacticipant_ids
  [consumer_id, provider_id]
end
provider_name() click to toggle source
# File lib/pact_broker/integrations/integration.rb, line 135
def provider_name
  provider.name
end
to_s() click to toggle source
# File lib/pact_broker/integrations/integration.rb, line 143
def to_s
  "Integration: consumer #{associations[:consumer]&.name || consumer_id}/provider #{associations[:provider]&.name || provider_id}"
end
verification_status_for_latest_pact() click to toggle source

TODO make this the verification status for the latest from main branch

# File lib/pact_broker/integrations/integration.rb, line 115
def verification_status_for_latest_pact
  @verification_status_for_latest_pact ||= PactBroker::Verifications::PseudoBranchStatus.new(latest_pact, latest_pact&.latest_verification)
end