Skip to content

Commit

Permalink
fix(versions): eager load associations for versions endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Nov 23, 2022
1 parent 2b6b629 commit 2a57dc4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/pact_broker/pacticipants/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,15 @@ def find options = {}

def find_all_pacticipant_versions_in_reverse_order name, pagination_options = nil
pacticipant = pacticipant_repository.find_by_name!(name)
query = PactBroker::Domain::Version.where(pacticipant: pacticipant).reverse_order(:order)
query = PactBroker::Domain::Version
.where(pacticipant: pacticipant)
.eager(:pacticipant)
.eager(branch_versions: [:version, :branch_head, { branch: :pacticipant }])
.eager(tags: :head_tag)
.eager(:pact_publications)
.reverse_order(:order)
query = query.paginate(pagination_options[:page_number], pagination_options[:page_size]) if pagination_options
query
query.all
end

def find_by_name_or_create name
Expand Down

0 comments on commit 2a57dc4

Please sign in to comment.