-
-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add test results to all verifications views
- Loading branch information
Showing
5 changed files
with
157 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
db/migrations/20190909_add_test_results_to_all_verifications.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,36 @@ | ||
Sequel.migration do | ||
up do | ||
create_or_replace_view(:all_verifications, | ||
from(:verifications).select( | ||
Sequel[:verifications][:id], | ||
Sequel[:verifications][:number], | ||
:success, | ||
:provider_version_id, | ||
Sequel[:v][:number].as(:provider_version_number), | ||
Sequel[:v][:order].as(:provider_version_order), | ||
:build_url, | ||
:pact_version_id, | ||
:execution_date, | ||
Sequel[:verifications][:created_at], | ||
:test_results | ||
).join(:versions, {id: :provider_version_id}, {:table_alias => :v}) | ||
) | ||
end | ||
|
||
down do | ||
create_or_replace_view(:all_verifications, | ||
from(:verifications).select( | ||
Sequel[:verifications][:id], | ||
Sequel[:verifications][:number], | ||
:success, | ||
:provider_version_id, | ||
Sequel[:v][:number].as(:provider_version_number), | ||
Sequel[:v][:order].as(:provider_version_order), | ||
:build_url, | ||
:pact_version_id, | ||
:execution_date, | ||
Sequel[:verifications][:created_at] | ||
).join(:versions, {id: :provider_version_id}, {:table_alias => :v}) | ||
) | ||
end | ||
end |
61 changes: 61 additions & 0 deletions
61
db/migrations/20190910_add_test_results_to_latest_verifications.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,61 @@ | ||
Sequel.migration do | ||
up do | ||
# The most recent verification for each pact_version | ||
# provider_version column is DEPRECATED, use provider_version_number | ||
# Think this can be replaced by latest_verification_id_for_pact_version_and_provider_version? | ||
v = :verifications | ||
create_or_replace_view(:latest_verifications, | ||
from(v) | ||
.select( | ||
Sequel[v][:id], | ||
Sequel[v][:number], | ||
Sequel[v][:success], | ||
Sequel[:s][:number].as(:provider_version), | ||
Sequel[v][:build_url], | ||
Sequel[v][:pact_version_id], | ||
Sequel[v][:execution_date], | ||
Sequel[v][:created_at], | ||
Sequel[v][:provider_version_id], | ||
Sequel[:s][:number].as(:provider_version_number), | ||
Sequel[:s][:order].as(:provider_version_order), | ||
Sequel[v][:test_results]) | ||
.join(:latest_verification_numbers, | ||
{ | ||
Sequel[v][:pact_version_id] => Sequel[:lv][:pact_version_id], | ||
Sequel[v][:number] => Sequel[:lv][:latest_number] | ||
}, { table_alias: :lv }) | ||
.join(:versions, | ||
{ | ||
Sequel[v][:provider_version_id] => Sequel[:s][:id] | ||
}, { table_alias: :s }) | ||
) | ||
end | ||
|
||
down do | ||
v = :verifications | ||
create_or_replace_view(:latest_verifications, | ||
from(v) | ||
.select( | ||
Sequel[v][:id], | ||
Sequel[v][:number], | ||
Sequel[v][:success], | ||
Sequel[:s][:number].as(:provider_version), | ||
Sequel[v][:build_url], | ||
Sequel[v][:pact_version_id], | ||
Sequel[v][:execution_date], | ||
Sequel[v][:created_at], | ||
Sequel[v][:provider_version_id], | ||
Sequel[:s][:number].as(:provider_version_number), | ||
Sequel[:s][:order].as(:provider_version_order)) | ||
.join(:latest_verification_numbers, | ||
{ | ||
Sequel[v][:pact_version_id] => Sequel[:lv][:pact_version_id], | ||
Sequel[v][:number] => Sequel[:lv][:latest_number] | ||
}, { table_alias: :lv }) | ||
.join(:versions, | ||
{ | ||
Sequel[v][:provider_version_id] => Sequel[:s][:id] | ||
}, { table_alias: :s }) | ||
) | ||
end | ||
end |
58 changes: 58 additions & 0 deletions
58
db/migrations/20190911_add_test_results_to_latest_verifications_for_pact_versions.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,58 @@ | ||
Sequel.migration do | ||
up do | ||
# The most recent verification for each pact_version | ||
v = :verifications | ||
create_or_replace_view(:latest_verifications_for_pact_versions, | ||
from(v) | ||
.select( | ||
Sequel[v][:id], | ||
Sequel[v][:number], | ||
Sequel[v][:success], | ||
Sequel[v][:build_url], | ||
Sequel[v][:pact_version_id], | ||
Sequel[v][:execution_date], | ||
Sequel[v][:created_at], | ||
Sequel[v][:provider_version_id], | ||
Sequel[:s][:number].as(:provider_version_number), | ||
Sequel[:s][:order].as(:provider_version_order), | ||
Sequel[v][:test_results]) | ||
.join(:latest_verification_ids_for_pact_versions, | ||
{ | ||
Sequel[v][:pact_version_id] => Sequel[:lv][:pact_version_id], | ||
Sequel[v][:id] => Sequel[:lv][:latest_verification_id] | ||
}, { table_alias: :lv }) | ||
.join(:versions, | ||
{ | ||
Sequel[v][:provider_version_id] => Sequel[:s][:id] | ||
}, { table_alias: :s }) | ||
) | ||
end | ||
|
||
down do | ||
# The most recent verification for each pact_version | ||
v = :verifications | ||
create_view(:latest_verifications_for_pact_versions, | ||
from(v) | ||
.select( | ||
Sequel[v][:id], | ||
Sequel[v][:number], | ||
Sequel[v][:success], | ||
Sequel[v][:build_url], | ||
Sequel[v][:pact_version_id], | ||
Sequel[v][:execution_date], | ||
Sequel[v][:created_at], | ||
Sequel[v][:provider_version_id], | ||
Sequel[:s][:number].as(:provider_version_number), | ||
Sequel[:s][:order].as(:provider_version_order)) | ||
.join(:latest_verification_ids_for_pact_versions, | ||
{ | ||
Sequel[v][:pact_version_id] => Sequel[:lv][:pact_version_id], | ||
Sequel[v][:id] => Sequel[:lv][:latest_verification_id] | ||
}, { table_alias: :lv }) | ||
.join(:versions, | ||
{ | ||
Sequel[v][:provider_version_id] => Sequel[:s][:id] | ||
}, { table_alias: :s }) | ||
) | ||
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