Sha256: 9e66a43e79cfec76fbe863815ae7ec61f2b5b472b8925ab0e314d35fadddaa34

Contents?: true

Size: 1.43 KB

Versions: 2

Compression:

Stored size: 1.43 KB

Contents

require 'pact_broker/db'
require 'pact_broker/verifications/pseudo_branch_status'
require 'pact_broker/domain/verification'

module PactBroker
  module Integrations
    class Integration < Sequel::Model
      associate(:many_to_one, :consumer, :class => "PactBroker::Domain::Pacticipant", :key => :consumer_id, :primary_key => :id)
      associate(:many_to_one, :provider, :class => "PactBroker::Domain::Pacticipant", :key => :provider_id, :primary_key => :id)
      associate(:one_to_one, :latest_pact, :class => "PactBroker::Pacts::LatestPactPublications", key: [:consumer_id, :provider_id], primary_key: [:consumer_id, :provider_id])
      associate(:one_to_one, :latest_verification, :class => "PactBroker::Verifications::LatestVerificationForConsumerAndProvider", key: [:consumer_id, :provider_id], primary_key: [:consumer_id, :provider_id])

      def verification_status_for_latest_pact
        @verification_status_for_latest_pact ||= PactBroker::Verifications::PseudoBranchStatus.new(latest_pact, latest_pact&.latest_verification)
      end

      def latest_pact_or_verification_publication_date
        [latest_pact.created_at, latest_verification_publication_date].compact.max
      end

      def latest_verification_publication_date
        latest_verification&.execution_date
      end
    end
  end
end

# Table: integrations
# Columns:
#  consumer_id   | integer |
#  consumer_name | text    |
#  provider_id   | integer |
#  provider_name | text    |

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pact_broker-2.40.0 lib/pact_broker/integrations/integration.rb
pact_broker-2.39.0 lib/pact_broker/integrations/integration.rb