-
-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dashboard api): optimise dashboard query by creating manual mate…
…rialized views for the matrix Dashboard query was taking 20 seconds.
- Loading branch information
Showing
12 changed files
with
190 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
Sequel.migration do | ||
up do | ||
create_table(:materialized_matrix, charset: 'utf8') do | ||
Integer :consumer_id, null: false | ||
String :consumer_name, null: false | ||
Integer :consumer_version_id, null: false | ||
String :consumer_version_number, null: false | ||
Integer :consumer_version_order, null: false | ||
Integer :pact_publication_id, null: false | ||
Integer :pact_version_id, null: false | ||
String :pact_version_sha, null: false | ||
Integer :pact_revision_number, null: false | ||
DateTime :pact_created_at, null: false | ||
Integer :provider_id, null: false | ||
String :provider_name, null: false | ||
Integer :provider_version_id | ||
String :provider_version_number | ||
Integer :provider_version_order | ||
Integer :verification_id | ||
Boolean :success | ||
Integer :verification_number | ||
DateTime :verification_executed_at | ||
String :verification_build_url | ||
index [:consumer_id], name: 'ndx_mm_consumer_id' | ||
index [:provider_id], name: 'ndx_mm_provider_id' | ||
index [:consumer_version_order], name: 'ndx_mm_cv_ord' | ||
end | ||
|
||
from(:materialized_matrix).insert(from(:matrix).select_all) | ||
end | ||
|
||
down do | ||
drop_table(:materialized_matrix) | ||
end | ||
end |
35 changes: 35 additions & 0 deletions
35
db/migrations/20180131_create_materialized_latest_matrix.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,35 @@ | ||
Sequel.migration do | ||
up do | ||
create_table(:materialized_latest_matrix, charset: 'utf8') do | ||
Integer :consumer_id, null: false | ||
String :consumer_name, null: false | ||
Integer :consumer_version_id, null: false | ||
String :consumer_version_number, null: false | ||
Integer :consumer_version_order, null: false | ||
Integer :pact_publication_id, null: false | ||
Integer :pact_version_id, null: false | ||
String :pact_version_sha, null: false | ||
Integer :pact_revision_number, null: false | ||
DateTime :pact_created_at, null: false | ||
Integer :provider_id, null: false | ||
String :provider_name, null: false | ||
Integer :provider_version_id | ||
String :provider_version_number | ||
Integer :provider_version_order | ||
Integer :verification_id | ||
Boolean :success | ||
Integer :verification_number | ||
DateTime :verification_executed_at | ||
String :verification_build_url | ||
index [:consumer_id], name: 'ndx_mlm_consumer_id' | ||
index [:provider_id], name: 'ndx_mlm_provider_id' | ||
index [:consumer_version_order], name: 'ndx_mlm_cv_ord' | ||
end | ||
|
||
from(:materialized_latest_matrix).insert(from(:latest_matrix).select_all) | ||
end | ||
|
||
down do | ||
drop_table(:materialized_latest_matrix) | ||
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,20 @@ class TestDataBuilder | |
attr_reader :webhook | ||
attr_reader :webhook_execution | ||
attr_reader :triggered_webhook | ||
attr_accessor :auto_refresh_matrix | ||
|
||
def initialize(params = {}) | ||
@auto_refresh_matrix = params.fetch(:auto_refresh_matrix, true) | ||
end | ||
|
||
def refresh_matrix | ||
if auto_refresh_matrix | ||
params = {} | ||
params[:consumer_name] = consumer.name if consumer | ||
params[:provider_name] = provider.name if provider | ||
matrix_service.refresh(params) | ||
end | ||
end | ||
|
||
def create_pricing_service | ||
@pricing_service_id = pacticipant_repository.create(:name => 'Pricing Service', :repository_url => '[email protected]:business-systems/pricing-service').save(raise_on_save_failure: true).id | ||
|
@@ -185,6 +199,7 @@ def create_pact params = {} | |
set_created_at_if_set params[:created_at], :pact_publications, {id: @pact.id} | ||
set_created_at_if_set params[:created_at], :pact_versions, {sha: @pact.pact_version_sha} | ||
@pact = PactBroker::Pacts::PactPublication.find(id: @pact.id).to_domain | ||
refresh_matrix | ||
self | ||
end | ||
|
||
|
@@ -253,6 +268,7 @@ def create_verification parameters = {} | |
PactBroker::Domain::Tag.create(name: tag_name, version: provider_version) | ||
end | ||
end | ||
refresh_matrix | ||
self | ||
end | ||
|
||
|