From 52efbcab17eca14723eb0acc38c451f761648e93 Mon Sep 17 00:00:00 2001 From: Beth Skurrie Date: Tue, 21 Dec 2021 13:39:48 +1100 Subject: [PATCH] chore(metrics): query distinct consumer_id/provider_id to determine integration count --- lib/pact_broker/metrics/service.rb | 2 +- spec/lib/pact_broker/metrics/service_spec.rb | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/pact_broker/metrics/service.rb b/lib/pact_broker/metrics/service.rb index ee51603dc..f83aa1611 100644 --- a/lib/pact_broker/metrics/service.rb +++ b/lib/pact_broker/metrics/service.rb @@ -18,7 +18,7 @@ def metrics withMainBranchSetCount: PactBroker::Domain::Pacticipant.with_main_branch_set.count }, integrations: { - count: PactBroker::Integrations::Integration.count + count: PactBroker::Pacts::PactPublication.select(:consumer_id, :provider_id).distinct.count }, pactPublications: { count: PactBroker::Pacts::PactPublication.count, diff --git a/spec/lib/pact_broker/metrics/service_spec.rb b/spec/lib/pact_broker/metrics/service_spec.rb index 01cbe1bfe..7fa07f43f 100644 --- a/spec/lib/pact_broker/metrics/service_spec.rb +++ b/spec/lib/pact_broker/metrics/service_spec.rb @@ -16,6 +16,18 @@ module Service its([:pacticipants, :withMainBranchSetCount]) { is_expected.to eq 1 } end + describe "integrations" do + before do + td.create_pact_with_hierarchy("Foo", "1", "Bar") + .create_pact_with_hierarchy("Foo", "1", "Bar2") + .create_consumer("NoPactConsumer") + .create_provider("NoPactProvider") + .create_integration + end + + its([:integrations, :count]) { is_expected.to eq 2 } + end + describe "pacticipant versions" do before do td.create_consumer("Foo")