Class: PactBroker::Integrations::Integration

Inherits:
Object
  • Object
show all
Defined in:
lib/pact_broker/integrations/integration.rb

Constant Summary collapse

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.

proc do |eo_opts|
  eo_opts[:rows].each do |integration|
    integration.associations[:latest_pact] = nil
  end

  PactBroker::Pacts::PactPublication.overall_latest.each do | pact |
    eo_opts[:rows].each do | integration |
      if integration.consumer_id == pact.consumer_id && integration.provider_id == pact.provider_id
        integration.associations[:latest_pact] = pact
      end
    end
  end
end

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.compare_by_last_action_date(a, b) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
# File 'lib/pact_broker/integrations/integration.rb', line 56

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

Instance Method Details

#<=>(other) ⇒ Object



80
81
82
# File 'lib/pact_broker/integrations/integration.rb', line 80

def <=>(other)
  [consumer_name.downcase, provider_name.downcase] <=> [other.consumer_name.downcase, other.provider_name.downcase]
end

#consumer_nameObject



84
85
86
# File 'lib/pact_broker/integrations/integration.rb', line 84

def consumer_name
  consumer.name
end

#latest_pact_or_verification_publication_dateObject



72
73
74
# File 'lib/pact_broker/integrations/integration.rb', line 72

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

#latest_verification_publication_dateObject



76
77
78
# File 'lib/pact_broker/integrations/integration.rb', line 76

def latest_verification_publication_date
  latest_verification&.execution_date
end

#provider_nameObject



88
89
90
# File 'lib/pact_broker/integrations/integration.rb', line 88

def provider_name
  provider.name
end

#verification_status_for_latest_pactObject



68
69
70
# File 'lib/pact_broker/integrations/integration.rb', line 68

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