Skip to content

Commit

Permalink
fix: add test results to all verifications views
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Sep 9, 2019
1 parent 1ab8a5d commit 9bc1eab
Show file tree
Hide file tree
Showing 5 changed files with 157 additions and 0 deletions.
36 changes: 36 additions & 0 deletions db/migrations/20190909_add_test_results_to_all_verifications.rb
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 db/migrations/20190910_add_test_results_to_latest_verifications.rb
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
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
1 change: 1 addition & 0 deletions lib/pact_broker/verifications/all_verifications.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ def provider
# pact_version_id | integer |
# execution_date | timestamp without time zone |
# created_at | timestamp without time zone |
# test_results | text |
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ def provider
# provider_version_id | integer |
# provider_version_number | text |
# provider_version_order | integer |
# test_results | text |

0 comments on commit 9bc1eab

Please sign in to comment.