@@ -34,13 +34,19 @@ def metrics
34
34
pactVersions : {
35
35
count : PactBroker ::Pacts ::PactVersion . count
36
36
} ,
37
- pactRevisions : {
38
- counts : pact_revision_counts
37
+ pactRevisionsPerConsumerVersion : {
38
+ distribution : pact_revision_counts
39
39
} ,
40
40
verificationResults : {
41
41
count : PactBroker ::Domain ::Verification . count ,
42
- first : format_date_time ( PactBroker ::Domain ::Verification . order ( :id ) . first . created_at ) ,
43
- last : format_date_time ( PactBroker ::Domain ::Verification . order ( :id ) . last . created_at )
42
+ successCount : PactBroker ::Domain ::Verification . where ( success : true ) . count ,
43
+ failureCount : PactBroker ::Domain ::Verification . where ( success : false ) . count ,
44
+ distinctCount : PactBroker ::Domain ::Verification . distinct . select ( :provider_version_id , :pact_version_id , :success ) . count ,
45
+ first : format_date_time ( PactBroker ::Domain ::Verification . order ( :id ) . first &.created_at ) ,
46
+ last : format_date_time ( PactBroker ::Domain ::Verification . order ( :id ) . last &.created_at ) ,
47
+ } ,
48
+ verificationResultsPerPactVersion : {
49
+ distribution : verification_distribution
44
50
} ,
45
51
pacticipantVersions : {
46
52
count : PactBroker ::Domain ::Version . count
@@ -66,9 +72,19 @@ def metrics
66
72
def pact_revision_counts
67
73
query = "select revision_count as number_of_revisions, count(consumer_version_id) as consumer_version_count
68
74
from (select consumer_version_id, count(*) as revision_count from pact_publications group by consumer_version_id) foo
69
- group by revision_count"
75
+ group by revision_count
76
+ order by 1"
70
77
PactBroker ::Pacts ::PactPublication . db [ query ] . all . each_with_object ( { } ) { |row , hash | hash [ row [ :number_of_revisions ] ] = row [ :consumer_version_count ] }
71
78
end
79
+
80
+ #
81
+ def verification_distribution
82
+ query = "select verification_count as number_of_verifications, count(*) as pact_version_count
83
+ from (select pact_version_id, count(*) as verification_count from verifications group by pact_version_id) foo
84
+ group by verification_count
85
+ order by 1"
86
+ PactBroker ::Pacts ::PactPublication . db [ query ] . all . each_with_object ( { } ) { |row , hash | hash [ row [ :number_of_verifications ] ] = row [ :pact_version_count ] }
87
+ end
72
88
end
73
89
end
74
90
end
0 commit comments