Skip to content

Commit

Permalink
feat: optimise query to automatically determine integrations
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Dec 23, 2019
1 parent 4817c35 commit 147cbfb
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/pact_broker/matrix/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 147cbfb

Please sign in to comment.