Skip to content

Commit 147cbfb

Browse files
committed
feat: optimise query to automatically determine integrations
1 parent 4817c35 commit 147cbfb

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/pact_broker/matrix/repository.rb

+4-2
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,14 @@ def find_compatible_pacticipant_versions selectors
8282
def find_integrations_for_specified_selectors(resolved_specified_selectors)
8383
specified_pacticipant_names = resolved_specified_selectors.collect(&:pacticipant_name)
8484

85+
# Must do select after matching selectors so we only select the columns we actually want
86+
# Otherwise we end up with a really long query!
8587
QuickRow
8688
.matching_selectors(resolved_specified_selectors)
89+
.from_self
90+
.select(:consumer_name, :consumer_id, :provider_name, :provider_id)
8791
.distinct
88-
.all
8992
.collect(&:to_hash)
90-
.uniq
9193
.collect do | hash |
9294
required = is_a_row_for_this_integration_required?(specified_pacticipant_names, hash[:consumer_name])
9395
Integration.from_hash(hash.merge(required: required))

0 commit comments

Comments
 (0)