Class: PactBroker::Matrix::Repository
- Inherits:
-
Object
- Object
- PactBroker::Matrix::Repository
- Includes:
- Repositories, Repositories::Helpers
- Defined in:
- lib/pact_broker/matrix/repository.rb
Constant Summary collapse
- TP_COLS =
TODO move latest verification logic in to database
PactBroker::Matrix::Row::TP_COLS
- GROUP_BY_PROVIDER_VERSION_NUMBER =
[:consumer_name, :consumer_version_number, :provider_name, :provider_version_number]
- GROUP_BY_PROVIDER =
[:consumer_name, :consumer_version_number, :provider_name]
- GROUP_BY_PACT =
[:consumer_name, :provider_name]
Instance Method Summary collapse
-
#find(specified_selectors, options = {}) ⇒ Object
Return the latest matrix row (pact/verification) for each consumer_version_number/provider_version_number.
- #find_compatible_pacticipant_versions(selectors) ⇒ Object
- #find_for_consumer_and_provider(pacticipant_1_name, pacticipant_2_name) ⇒ Object
- #find_ids_for_pacticipant_names(params) ⇒ Object
- #find_integrations_for_specified_selectors(resolved_specified_selectors, infer_integrations) ⇒ Object
Methods included from Repositories
#label_repository, #matrix_repository, #pact_repository, #pacticipant_repository, #tag_repository, #verification_repository, #version_repository, #webhook_repository
Methods included from Repositories::Helpers
#mysql?, #name_like, #order_append_ignore_case, #order_ignore_case, #pacticipant_id_for_name, #postgres?, #select_all_qualified, #select_for_subquery
Instance Method Details
#find(specified_selectors, options = {}) ⇒ Object
Return the latest matrix row (pact/verification) for each consumer_version_number/provider_version_number
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/pact_broker/matrix/repository.rb', line 57 def find specified_selectors, = {} resolved_specified_selectors = resolve_versions_and_add_ids(specified_selectors, :specified) integrations = find_integrations_for_specified_selectors(resolved_specified_selectors, infer_selectors_for_integrations?()) resolved_selectors = if infer_selectors_for_integrations?() resolved_specified_selectors + inferred_selectors(resolved_specified_selectors, integrations, ) else resolved_specified_selectors end all_lines = query_matrix(resolved_selectors, ) lines = apply_latestby(, all_lines) # This needs to be done after the latestby, so can't be done in the db unless # the latestby logic is moved to the db if .key?(:success) lines = lines.select{ |l| [:success].include?(l.success) } end QueryResults.new(lines.sort, specified_selectors, , resolved_selectors, integrations) end |
#find_compatible_pacticipant_versions(selectors) ⇒ Object
84 85 86 |
# File 'lib/pact_broker/matrix/repository.rb', line 84 def find_compatible_pacticipant_versions selectors find(selectors, latestby: 'cvpv').select(&:success) end |
#find_for_consumer_and_provider(pacticipant_1_name, pacticipant_2_name) ⇒ Object
78 79 80 81 82 |
# File 'lib/pact_broker/matrix/repository.rb', line 78 def find_for_consumer_and_provider pacticipant_1_name, pacticipant_2_name selectors = [ UnresolvedSelector.new(pacticipant_name: pacticipant_1_name), UnresolvedSelector.new(pacticipant_name: pacticipant_2_name)] = { latestby: 'cvpv' } find(selectors, ) end |
#find_ids_for_pacticipant_names(params) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/pact_broker/matrix/repository.rb', line 32 def find_ids_for_pacticipant_names params criteria = {} if params[:consumer_name] || params[:provider_name] if params[:consumer_name] pacticipant = PactBroker::Domain::Pacticipant.where(name_like(:name, params[:consumer_name])).single_record criteria[:consumer_id] = pacticipant.id if pacticipant end if params[:provider_name] pacticipant = PactBroker::Domain::Pacticipant.where(name_like(:name, params[:provider_name])).single_record criteria[:provider_id] = pacticipant.id if pacticipant end end if params[:pacticipant_name] pacticipant = PactBroker::Domain::Pacticipant.where(name_like(:name, params[:pacticipant_name])).single_record criteria[:pacticipant_id] = pacticipant.id if pacticipant end criteria[:tag_name] = params[:tag_name] if params[:tag_name].is_a?(String) # Could be a sym from resource parameters in api.rb criteria end |
#find_integrations_for_specified_selectors(resolved_specified_selectors, infer_integrations) ⇒ Object
88 89 90 91 92 93 94 95 96 97 |
# File 'lib/pact_broker/matrix/repository.rb', line 88 def find_integrations_for_specified_selectors(resolved_specified_selectors, infer_integrations) specified_pacticipant_names = resolved_specified_selectors.collect(&:pacticipant_name) QuickRow .distinct_integrations(resolved_specified_selectors, infer_integrations) .collect(&:to_hash) .collect do | hash | required = is_a_row_for_this_integration_required?(specified_pacticipant_names, hash[:consumer_name]) Integration.from_hash(hash.merge(required: required)) end end |