From 147cbfb64c5d9cc08709b476b7e540d9260e09ee Mon Sep 17 00:00:00 2001 From: Beth Skurrie Date: Mon, 23 Dec 2019 20:17:35 +1100 Subject: [PATCH] feat: optimise query to automatically determine integrations --- lib/pact_broker/matrix/repository.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/pact_broker/matrix/repository.rb b/lib/pact_broker/matrix/repository.rb index d3f107bfe..3dbc7e314 100644 --- a/lib/pact_broker/matrix/repository.rb +++ b/lib/pact_broker/matrix/repository.rb @@ -82,12 +82,14 @@ def find_compatible_pacticipant_versions selectors def find_integrations_for_specified_selectors(resolved_specified_selectors) specified_pacticipant_names = resolved_specified_selectors.collect(&:pacticipant_name) + # Must do select after matching selectors so we only select the columns we actually want + # Otherwise we end up with a really long query! QuickRow .matching_selectors(resolved_specified_selectors) + .from_self + .select(:consumer_name, :consumer_id, :provider_name, :provider_id) .distinct - .all .collect(&:to_hash) - .uniq .collect do | hash | required = is_a_row_for_this_integration_required?(specified_pacticipant_names, hash[:consumer_name]) Integration.from_hash(hash.merge(required: required))