Class: PactBroker::Integrations::Service

Inherits:
Object
  • Object
show all
Extended by:
Repositories, Services
Includes:
Logging
Defined in:
lib/pact_broker/integrations/service.rb

Class Method Summary collapse

Methods included from Repositories

label_repository, matrix_repository, pact_repository, pacticipant_repository, tag_repository, verification_repository, version_repository, webhook_repository

Methods included from Services

badge_service, certificate_service, group_service, index_service, integration_service, label_service, matrix_service, metrics_service, pact_service, pacticipant_service, tag_service, verification_service, version_service, webhook_service, webhook_trigger_service

Methods included from Logging

included, #log_error

Class Method Details

.delete(consumer_name, provider_name) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/pact_broker/integrations/service.rb', line 31

def self.delete(consumer_name, provider_name)
  consumer = pacticipant_service.find_pacticipant_by_name(consumer_name)
  provider = pacticipant_service.find_pacticipant_by_name(provider_name)
  # this takes care of the triggered webhooks and webhook executions
  pact_service.delete_all_pact_publications_between(consumer_name, and: provider_name)
  verification_service.delete_all_verifications_between(consumer_name, and: provider_name)
  pact_service.delete_all_pact_versions_between(consumer_name, and: provider_name)
  webhook_repository.delete_by_consumer_and_provider(consumer, provider)
  version_repository.delete_orphan_versions(consumer, provider)

  pacticipant_service.delete_if_orphan(consumer)
  pacticipant_service.delete_if_orphan(provider) unless consumer == provider
end

.find_allObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/pact_broker/integrations/service.rb', line 13

def self.find_all
  # The only reason the pact_version needs to be loaded is that
  # the Verification::PseudoBranchStatus uses it to determine if
  # the pseudo branch is 'stale'.
  # Because this is the status for a pact, and not a pseudo branch,
  # the status can never be 'stale',
  # so it would be better to create a Verification::PactStatus class
  # that doesn't have the 'stale' logic in it.
  # Then we can remove the eager loading of the pact_version
  PactBroker::Integrations::Integration
    .eager(:consumer)
    .eager(:provider)
    .eager(latest_pact: [:latest_verification, :pact_version])
    .eager(:latest_verification)
    .all
    .sort { | a, b| b.latest_pact_or_verification_publication_date <=> a.latest_pact_or_verification_publication_date }
end