Sha256: a8425a7c91fbe0198ce2395b104b042bd3a1c37261baff214b6319b7f7139b81

Contents?: true

Size: 1.41 KB

Versions: 21

Compression:

Stored size: 1.41 KB

Contents

module PactBroker
  module Pacts
    module LazyLoaders
      HEAD_PACT_PUBLICATIONS_FOR_TAGS = lambda {
        consumer_version_tag_names = PactBroker::Domain::Tag.select(:name).where(version_id: consumer_version_id)
          PactPublication
            .for_consumer(consumer)
            .for_provider(provider)
            .latest_for_consumer_tag(consumer_version_tag_names)
            .from_self.order_by(:tag_name)
      }

      LATEST_VERIFICATION_FOR_CONSUMER_BRANCHES = lambda {
        bv_pp_join = {
          Sequel[:branch_versions][:version_id] => Sequel[:pact_publications][:consumer_version_id],
          Sequel[:pact_publications][:provider_id] => provider_id
        }

        verifications_join = {
          Sequel[:verifications][:pact_version_id] => Sequel[:pact_publications][:pact_version_id]
        }

        branch_ids = PactBroker::Versions::BranchVersion
          .select(:branch_id)
          .where(version_id: consumer_version_id)


        latest_verification_id = PactBroker::Versions::BranchVersion
          .select(Sequel[:verifications][:id])
          .where(Sequel[:branch_versions][:branch_id] => branch_ids)
          .join(:pact_publications, bv_pp_join)
          .join(:verifications, verifications_join)
          .order(Sequel.desc(Sequel[:verifications][:id]))
          .limit(1)

        PactBroker::Domain::Verification.where(id: latest_verification_id)
      }
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
pact_broker-2.96.0 lib/pact_broker/pacts/lazy_loaders.rb