Class: PactBroker::Integrations::Service
- Inherits:
-
Object
- Object
- PactBroker::Integrations::Service
- Extended by:
- Repositories, Repositories::Scopes, Services
- Includes:
- Logging
- Defined in:
- lib/pact_broker/integrations/service.rb
Constant Summary
Constants included from Services
Class Method Summary collapse
- .delete(consumer_name, provider_name) ⇒ Object
- .delete_all ⇒ Object
- .find_all ⇒ Object
- .find_for_provider(provider) ⇒ Object
Methods included from Repositories
branch_version_repository, integration_repository, label_repository, matrix_repository, pact_repository, pacticipant_repository, tag_repository, verification_repository, version_repository, webhook_repository
Methods included from Services
badge_service, branch_service, certificate_service, contract_service, deployed_version_service, environment_service, get, group_service, index_service, integration_service, label_service, matrix_service, metrics_service, pact_service, pacticipant_service, register_default_services, register_service, released_version_service, tag_service, verification_service, version_service, webhook_service, webhook_trigger_service
Methods included from Repositories::Scopes
scope_for, unscoped, with_no_scope
Methods included from Logging
included, #log_error, #log_with_tag
Class Method Details
.delete(consumer_name, provider_name) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/pact_broker/integrations/service.rb', line 35 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) integration_repository.delete(consumer.id, provider.id) pacticipant_service.delete_if_orphan(consumer) pacticipant_service.delete_if_orphan(provider) unless consumer == provider end |
.delete_all ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/pact_broker/integrations/service.rb', line 49 def self.delete_all # TODO move all these into their own repositories PactBroker::DB.each_integration_model do | model | if PactBroker::Repositories::Helpers.postgres? logger.info("Truncating ", model.table_name) model.truncate(cascade: true) else logger.info("Deleting all from ", model.table_name) # Mysql adapter needs to support cascade truncate # https://travis-ci.org/pact-foundation/pact_broker/jobs/633050220#L841 # https://travis-ci.org/pact-foundation/pact_broker/jobs/633053228#L849 model.dataset.delete end end end |
.find_all ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/pact_broker/integrations/service.rb', line 17 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 scope_for(PactBroker::Integrations::Integration) .eager(:consumer) .eager(:provider) .eager(latest_pact: [:latest_verification, :pact_version]) .eager(:latest_verification) .all .sort { | a, b| Integration.compare_by_last_action_date(a, b) } end |
.find_for_provider(provider) ⇒ Object
65 66 67 |
# File 'lib/pact_broker/integrations/service.rb', line 65 def self.find_for_provider(provider) scope_for(PactBroker::Integrations::Integration).where(provider_id: provider.id).eager(:consumer).eager(:provider).all.sort end |