-
-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(matrix): use views to create matrix query
- Loading branch information
Showing
13 changed files
with
230 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
db/migrations/000049_create_latest_verifications_for_cv_and_pv.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Sequel.migration do | ||
change do | ||
# joining with latest_pact_publication_revision_numbers gets rid of the overwritten | ||
# pact revisions, and the max(verification_id) gets rid of the overwritten | ||
# verifications | ||
create_view(:latest_verification_id_for_consumer_version_and_provider_version, | ||
"select consumer_version_id, provider_version_id, max(verification_id) as latest_verification_id | ||
from matrix | ||
inner join latest_pact_publication_revision_numbers lr | ||
on matrix.consumer_id = lr.consumer_id | ||
and matrix.provider_id = lr.provider_id | ||
and matrix.consumer_version_order = lr.consumer_version_order | ||
and matrix.pact_revision_number = lr.latest_revision_number | ||
group by consumer_version_id, provider_version_id" | ||
) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Sequel.migration do | ||
change do | ||
# Removes 'overwritten' pacts and verifications from the matrix | ||
# (ie. only show latest pact revision for each consumer version and | ||
# latest verification for each provider version) | ||
# Must include lines where verification_id is null so that we don't | ||
# lose the unverified pacts. | ||
create_view(:latest_matrix, | ||
"SELECT matrix.* FROM matrix | ||
INNER JOIN latest_verification_id_for_consumer_version_and_provider_version AS lv | ||
ON ((matrix.consumer_version_id = lv.consumer_version_id) | ||
AND (matrix.provider_version_id = lv.provider_version_id) | ||
AND ((matrix.verification_id = lv.latest_verification_id))) | ||
UNION | ||
select * from matrix where verification_id is null" | ||
) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
require 'pact_broker/matrix/row' | ||
|
||
module PactBroker | ||
module Matrix | ||
|
||
# Latest pact revision for each consumer version => latest verification | ||
|
||
class LatestRow < Row | ||
set_dataset(:latest_matrix) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.