pact_broker 2.96.0 → 2.99.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +43 -0
- data/Gemfile +1 -0
- data/docs/CONFIGURATION.md +131 -67
- data/lib/db.rb +1 -7
- data/lib/pact_broker/api/middleware/http_debug_logs.rb +42 -0
- data/lib/pact_broker/api/resources/base_resource.rb +4 -0
- data/lib/pact_broker/api/resources/latest_pacts.rb +1 -1
- data/lib/pact_broker/api/resources/pact.rb +0 -8
- data/lib/pact_broker/api/resources/pact_content_diff.rb +7 -2
- data/lib/pact_broker/api/resources/pact_versions.rb +1 -5
- data/lib/pact_broker/api/resources/pact_versions_for_branch.rb +1 -5
- data/lib/pact_broker/api/resources/provider_pacts.rb +1 -1
- data/lib/pact_broker/api/resources/tagged_pact_versions.rb +1 -5
- data/lib/pact_broker/api/resources/verification.rb +0 -4
- data/lib/pact_broker/api/resources/verifications.rb +0 -4
- data/lib/pact_broker/api/resources/version.rb +8 -0
- data/lib/pact_broker/app.rb +3 -7
- data/lib/pact_broker/config/runtime_configuration.rb +24 -5
- data/lib/pact_broker/config/runtime_configuration_coercion_methods.rb +11 -0
- data/lib/pact_broker/config/runtime_configuration_database_methods.rb +2 -2
- data/lib/pact_broker/config/runtime_configuration_logging_methods.rb +7 -2
- data/lib/pact_broker/configuration.rb +2 -0
- data/lib/pact_broker/db/models.rb +2 -2
- data/lib/pact_broker/index/service.rb +1 -2
- data/lib/pact_broker/integrations/integration.rb +21 -6
- data/lib/pact_broker/integrations/service.rb +1 -1
- data/lib/pact_broker/matrix/every_row.rb +19 -1
- data/lib/pact_broker/matrix/integration.rb +5 -5
- data/lib/pact_broker/matrix/quick_row.rb +36 -3
- data/lib/pact_broker/matrix/repository.rb +4 -3
- data/lib/pact_broker/matrix/service.rb +0 -1
- data/lib/pact_broker/metrics/service.rb +2 -2
- data/lib/pact_broker/pacts/create_formatted_diff.rb +1 -0
- data/lib/pact_broker/pacts/eager_loaders.rb +4 -1
- data/lib/pact_broker/pacts/pact_publication.rb +9 -6
- data/lib/pact_broker/pacts/pact_publication_dataset_module.rb +25 -0
- data/lib/pact_broker/pacts/pact_publication_wip_dataset_module.rb +0 -15
- data/lib/pact_broker/pacts/pact_version.rb +24 -28
- data/lib/pact_broker/pacts/pact_version_association_loaders.rb +36 -0
- data/lib/pact_broker/pacts/pacts_for_verification_repository.rb +9 -13
- data/lib/pact_broker/pacts/repository.rb +29 -27
- data/lib/pact_broker/test/http_test_data_builder.rb +11 -2
- data/lib/pact_broker/test/test_data_builder.rb +2 -1
- data/lib/pact_broker/ui/controllers/matrix.rb +14 -11
- data/lib/pact_broker/ui/views/groups/show.html.erb +2 -2
- data/lib/pact_broker/version.rb +1 -1
- data/pact_broker.gemspec +1 -1
- metadata +9 -16
- data/lib/pact_broker/matrix/aggregated_row.rb +0 -79
- data/lib/pact_broker/matrix/head_row.rb +0 -80
- data/lib/pact_broker/matrix/row.rb +0 -287
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pact_broker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.99.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bethany Skurrie
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2022-
|
13
|
+
date: 2022-05-16 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: httparty
|
@@ -346,22 +346,16 @@ dependencies:
|
|
346
346
|
name: sanitize
|
347
347
|
requirement: !ruby/object:Gem::Requirement
|
348
348
|
requirements:
|
349
|
-
- -
|
350
|
-
- !ruby/object:Gem::Version
|
351
|
-
version: 5.2.1
|
352
|
-
- - "~>"
|
349
|
+
- - '='
|
353
350
|
- !ruby/object:Gem::Version
|
354
|
-
version: '
|
351
|
+
version: '6.0'
|
355
352
|
type: :runtime
|
356
353
|
prerelease: false
|
357
354
|
version_requirements: !ruby/object:Gem::Requirement
|
358
355
|
requirements:
|
359
|
-
- -
|
360
|
-
- !ruby/object:Gem::Version
|
361
|
-
version: 5.2.1
|
362
|
-
- - "~>"
|
356
|
+
- - '='
|
363
357
|
- !ruby/object:Gem::Version
|
364
|
-
version: '
|
358
|
+
version: '6.0'
|
365
359
|
- !ruby/object:Gem::Dependency
|
366
360
|
name: wisper
|
367
361
|
requirement: !ruby/object:Gem::Requirement
|
@@ -689,6 +683,7 @@ files:
|
|
689
683
|
- lib/pact_broker/api/decorators/webhooks_decorator.rb
|
690
684
|
- lib/pact_broker/api/middleware/basic_auth.rb
|
691
685
|
- lib/pact_broker/api/middleware/configuration.rb
|
686
|
+
- lib/pact_broker/api/middleware/http_debug_logs.rb
|
692
687
|
- lib/pact_broker/api/pact_broker_urls.rb
|
693
688
|
- lib/pact_broker/api/paths.rb
|
694
689
|
- lib/pact_broker/api/renderers/html_pact_renderer.rb
|
@@ -918,11 +913,9 @@ files:
|
|
918
913
|
- lib/pact_broker/locale/en.yml
|
919
914
|
- lib/pact_broker/logging.rb
|
920
915
|
- lib/pact_broker/logging/default_formatter.rb
|
921
|
-
- lib/pact_broker/matrix/aggregated_row.rb
|
922
916
|
- lib/pact_broker/matrix/can_i_deploy_query_schema.rb
|
923
917
|
- lib/pact_broker/matrix/deployment_status_summary.rb
|
924
918
|
- lib/pact_broker/matrix/every_row.rb
|
925
|
-
- lib/pact_broker/matrix/head_row.rb
|
926
919
|
- lib/pact_broker/matrix/integration.rb
|
927
920
|
- lib/pact_broker/matrix/parse_can_i_deploy_query.rb
|
928
921
|
- lib/pact_broker/matrix/parse_query.rb
|
@@ -934,7 +927,6 @@ files:
|
|
934
927
|
- lib/pact_broker/matrix/reason.rb
|
935
928
|
- lib/pact_broker/matrix/repository.rb
|
936
929
|
- lib/pact_broker/matrix/resolved_selector.rb
|
937
|
-
- lib/pact_broker/matrix/row.rb
|
938
930
|
- lib/pact_broker/matrix/service.rb
|
939
931
|
- lib/pact_broker/matrix/unresolved_selector.rb
|
940
932
|
- lib/pact_broker/messages.rb
|
@@ -963,6 +955,7 @@ files:
|
|
963
955
|
- lib/pact_broker/pacts/pact_publication_selector_dataset_module.rb
|
964
956
|
- lib/pact_broker/pacts/pact_publication_wip_dataset_module.rb
|
965
957
|
- lib/pact_broker/pacts/pact_version.rb
|
958
|
+
- lib/pact_broker/pacts/pact_version_association_loaders.rb
|
966
959
|
- lib/pact_broker/pacts/pacts_for_verification_repository.rb
|
967
960
|
- lib/pact_broker/pacts/parse.rb
|
968
961
|
- lib/pact_broker/pacts/placeholder_pact.rb
|
@@ -1229,7 +1222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
1229
1222
|
- !ruby/object:Gem::Version
|
1230
1223
|
version: '0'
|
1231
1224
|
requirements: []
|
1232
|
-
rubygems_version: 3.3.
|
1225
|
+
rubygems_version: 3.3.13
|
1233
1226
|
signing_key:
|
1234
1227
|
specification_version: 4
|
1235
1228
|
summary: See description
|
@@ -1,79 +0,0 @@
|
|
1
|
-
require "forwardable"
|
2
|
-
require "pact_broker/verifications/repository"
|
3
|
-
|
4
|
-
# A collection of matrix rows with the same pact publication id
|
5
|
-
# It's basically a normalised view of a denormalised view :(
|
6
|
-
# A pact publication may be the overall latest, and/or the latest for a tag
|
7
|
-
module PactBroker
|
8
|
-
module Matrix
|
9
|
-
class AggregatedRow
|
10
|
-
extend Forwardable
|
11
|
-
|
12
|
-
delegate [:consumer, :consumer_name, :consumer_version, :consumer_version_number, :consumer_version_order, :consumer_version_tags] => :first_row
|
13
|
-
delegate [:provider, :provider_name, :provider_version, :provider_version_number, :provider_version_order, :provider_version_tags] => :first_row
|
14
|
-
delegate [:pact, :pact_version, :pact_revision_number, :webhooks, :latest_triggered_webhooks, :'<=>'] => :first_row
|
15
|
-
delegate [:verification_id, :verification] => :first_row
|
16
|
-
|
17
|
-
def initialize matrix_rows
|
18
|
-
@matrix_rows = matrix_rows
|
19
|
-
@first_row = matrix_rows.first
|
20
|
-
end
|
21
|
-
|
22
|
-
def overall_latest?
|
23
|
-
!!matrix_rows.find{ | row| row.consumer_version_tag_name.nil? }
|
24
|
-
end
|
25
|
-
|
26
|
-
# If this comes back nil, it won't be "cached", but it's a reasonably
|
27
|
-
# quick query, so it's probably ok.
|
28
|
-
# The collection of pacts that belong to the same tag can be considered
|
29
|
-
# a pseudo branch. Find the latest verification for each pseudo branch
|
30
|
-
# and return the most recent. If this pact is the most recent overall,
|
31
|
-
# and there were no verifications found for any of the tags, then
|
32
|
-
# return the most recent verification
|
33
|
-
def latest_verification_for_pseudo_branch
|
34
|
-
@latest_verification ||= begin
|
35
|
-
verification = matrix_rows.collect do | row|
|
36
|
-
row.verification || latest_verification_for_consumer_version_tag(row)
|
37
|
-
end.compact.sort_by(&:id).last
|
38
|
-
|
39
|
-
if !verification && overall_latest?
|
40
|
-
overall_latest_verification
|
41
|
-
else
|
42
|
-
verification
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def latest_verification_for_pact_version
|
48
|
-
@latest_verificaton_for_pact_version ||= begin
|
49
|
-
matrix_rows.collect(&:verification).compact.sort_by(&:id).last
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
# The list of tag names for which this pact publication is the most recent with that tag
|
54
|
-
# There could, however, be a later consumer version that does't have a pact (perhaps because it was deleted)
|
55
|
-
# that has the same tag.
|
56
|
-
# TODO show a warning when the data is "corrupted" as above.
|
57
|
-
def consumer_head_tag_names
|
58
|
-
matrix_rows.collect(&:consumer_version_tag_name).compact
|
59
|
-
end
|
60
|
-
|
61
|
-
private
|
62
|
-
|
63
|
-
attr_reader :matrix_rows, :first_row
|
64
|
-
|
65
|
-
def latest_verification_for_consumer_version_tag row
|
66
|
-
row.latest_verification_for_consumer_version_tag if row.consumer_version_tag_name
|
67
|
-
end
|
68
|
-
|
69
|
-
def overall_latest_verification
|
70
|
-
# not eager loaded because it shouldn't be called that often
|
71
|
-
first_row.latest_verification_for_consumer_and_provider
|
72
|
-
end
|
73
|
-
|
74
|
-
def consumer_version_tag_names
|
75
|
-
matrix_rows.collect(&:consumer_version_tag_name)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
@@ -1,80 +0,0 @@
|
|
1
|
-
require "pact_broker/matrix/row"
|
2
|
-
require "pact_broker/webhooks/webhook"
|
3
|
-
|
4
|
-
module PactBroker
|
5
|
-
module Matrix
|
6
|
-
# A row for each of the overall latest pacts, and a row for each of the latest tagged pacts
|
7
|
-
# Rows with a nil consumer_tag_name are the overall latest
|
8
|
-
class HeadRow < Row
|
9
|
-
set_dataset(:head_matrix)
|
10
|
-
|
11
|
-
# one_to_one :latest_verification_for_consumer_version_tag,
|
12
|
-
# :class => "PactBroker::Verifications::LatestVerificationForConsumerVersionTag",
|
13
|
-
# primary_key: [:provider_id, :consumer_id, :consumer_version_tag_name], key: [:provider_id, :consumer_id, :consumer_version_tag_name]
|
14
|
-
|
15
|
-
# Loading the latest_verification_for_consumer_version_tag objects this way is quicker than
|
16
|
-
# doing it using an inbult relation with primary_key/key, if we are loading the relation for
|
17
|
-
# the entire HeadRow table
|
18
|
-
# Using the inbuilt relation puts constraints on the columns that are not necessary and slow
|
19
|
-
# the query down.
|
20
|
-
# This relation relies on consumer_version_tags already being loaded
|
21
|
-
one_to_one :latest_verification_for_consumer_version_tag, :class => "PactBroker::Verifications::LatestVerificationForConsumerVersionTag", primary_keys: [], key: [], :eager_loader=>(proc do |eo_opts|
|
22
|
-
# create an index of provider_id/consumer_id/consumer_version_tag_name => row
|
23
|
-
tag_to_row = eo_opts[:rows].each_with_object({}) { | row, map | map[[row.provider_id, row.consumer_id, row.consumer_version_tag_name]] = row }
|
24
|
-
# Initialise the association with nil - not sure why?
|
25
|
-
eo_opts[:rows].each{|row| row.associations[:latest_verification_for_consumer_version_tag] = nil}
|
26
|
-
|
27
|
-
# Need the all then the each to ensure the eager loading works
|
28
|
-
PactBroker::Verifications::LatestVerificationForConsumerVersionTag.each do | verification |
|
29
|
-
key = [verification.provider_id, verification.consumer_id, verification.consumer_version_tag_name]
|
30
|
-
if tag_to_row[key]
|
31
|
-
tag_to_row[key].associations[:latest_verification_for_consumer_version_tag] = verification
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end)
|
35
|
-
|
36
|
-
# When viewing the index, every webhook in the database will match at least one of the rows, so
|
37
|
-
# it makes sense to load the entire table and match each webhook to the appropriate row.
|
38
|
-
# This will only work when using eager loading. The keys are just blanked out to avoid errors.
|
39
|
-
# I don't understand how they work at all.
|
40
|
-
# It would be nice to do this declaratively.
|
41
|
-
many_to_many :webhooks, class: :'PactBroker::Webhooks::Webhook', :left_key => [], left_primary_key: [], :eager_loader=>(proc do |eo_opts|
|
42
|
-
eo_opts[:rows].each do |row|
|
43
|
-
row.associations[:webhooks] = []
|
44
|
-
end
|
45
|
-
|
46
|
-
PactBroker::Webhooks::Webhook.each do | webhook |
|
47
|
-
eo_opts[:rows].each do | row |
|
48
|
-
if webhook.is_for?(row)
|
49
|
-
row.associations[:webhooks] << webhook
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
# Table: head_matrix
|
59
|
-
# Columns:
|
60
|
-
# consumer_id | integer |
|
61
|
-
# consumer_name | text |
|
62
|
-
# consumer_version_id | integer |
|
63
|
-
# consumer_version_number | text |
|
64
|
-
# consumer_version_order | integer |
|
65
|
-
# pact_publication_id | integer |
|
66
|
-
# pact_version_id | integer |
|
67
|
-
# pact_version_sha | text |
|
68
|
-
# pact_revision_number | integer |
|
69
|
-
# pact_created_at | timestamp without time zone |
|
70
|
-
# provider_id | integer |
|
71
|
-
# provider_name | text |
|
72
|
-
# provider_version_id | integer |
|
73
|
-
# provider_version_number | text |
|
74
|
-
# provider_version_order | integer |
|
75
|
-
# verification_id | integer |
|
76
|
-
# success | boolean |
|
77
|
-
# verification_number | integer |
|
78
|
-
# verification_executed_at | timestamp without time zone |
|
79
|
-
# verification_build_url | text |
|
80
|
-
# consumer_version_tag_name | text |
|
@@ -1,287 +0,0 @@
|
|
1
|
-
require "pact_broker/repositories/helpers"
|
2
|
-
require "pact_broker/webhooks/latest_triggered_webhook"
|
3
|
-
require "pact_broker/tags/tag_with_latest_flag"
|
4
|
-
require "pact_broker/logging"
|
5
|
-
require "pact_broker/verifications/latest_verification_for_consumer_version_tag"
|
6
|
-
require "pact_broker/verifications/latest_verification_for_consumer_and_provider"
|
7
|
-
|
8
|
-
# TODO DELETE THIS!!!
|
9
|
-
|
10
|
-
module PactBroker
|
11
|
-
module Matrix
|
12
|
-
class Row < Sequel::Model(:matrix)
|
13
|
-
|
14
|
-
# Used when using table_print to output query results
|
15
|
-
TP_COLS = [ :consumer_version_number, :pact_revision_number, :provider_version_number, :verification_number]
|
16
|
-
|
17
|
-
associate(:one_to_many, :latest_triggered_webhooks, :class => "PactBroker::Webhooks::LatestTriggeredWebhook", primary_key: :pact_publication_id, key: :pact_publication_id)
|
18
|
-
associate(:one_to_many, :consumer_version_tags, :class => "PactBroker::Tags::TagWithLatestFlag", primary_key: :consumer_version_id, key: :version_id)
|
19
|
-
associate(:one_to_many, :provider_version_tags, :class => "PactBroker::Tags::TagWithLatestFlag", primary_key: :provider_version_id, key: :version_id)
|
20
|
-
|
21
|
-
many_to_one :latest_verification_for_consumer_and_provider,
|
22
|
-
:class => "PactBroker::Verifications::LatestVerificationForConsumerAndProvider",
|
23
|
-
primary_key: [:provider_id, :consumer_id], key: [:provider_id, :consumer_id]
|
24
|
-
|
25
|
-
dataset_module do
|
26
|
-
include PactBroker::Repositories::Helpers
|
27
|
-
include PactBroker::Logging
|
28
|
-
|
29
|
-
def consumer consumer_name
|
30
|
-
where(name_like(:consumer_name, consumer_name))
|
31
|
-
end
|
32
|
-
|
33
|
-
def provider provider_name
|
34
|
-
where(name_like(:provider_name, provider_name))
|
35
|
-
end
|
36
|
-
|
37
|
-
def matching_selectors selectors
|
38
|
-
if selectors.size == 1
|
39
|
-
where_consumer_or_provider_is(selectors.first)
|
40
|
-
else
|
41
|
-
where_consumer_and_provider_in(selectors)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
# find rows where (the consumer (and optional version) matches any of the selectors)
|
46
|
-
# AND
|
47
|
-
# the (provider (and optional version) matches any of the selectors OR the provider matches
|
48
|
-
# and the verification is missing (and hence the provider version is null))
|
49
|
-
def where_consumer_and_provider_in selectors
|
50
|
-
where{
|
51
|
-
Sequel.&(
|
52
|
-
Sequel.|(
|
53
|
-
*QueryHelper.consumer_and_maybe_consumer_version_match_any_selector(selectors)
|
54
|
-
),
|
55
|
-
Sequel.|(
|
56
|
-
*QueryHelper.provider_and_maybe_provider_version_match_any_selector_or_verification_is_missing(selectors)
|
57
|
-
),
|
58
|
-
QueryHelper.either_consumer_or_provider_was_specified_in_query(selectors)
|
59
|
-
)
|
60
|
-
}
|
61
|
-
end
|
62
|
-
|
63
|
-
# Can't access other dataset_module methods from inside the Sequel `where{ ... }` block, so make a private class
|
64
|
-
# with some helper methods
|
65
|
-
class QueryHelper
|
66
|
-
def self.consumer_and_maybe_consumer_version_match_any_selector(selectors)
|
67
|
-
selectors.collect { |s| consumer_and_maybe_consumer_version_match_selector(s) }
|
68
|
-
end
|
69
|
-
|
70
|
-
def self.consumer_and_maybe_consumer_version_match_selector(s)
|
71
|
-
if s[:pact_publication_ids]
|
72
|
-
Sequel.&(pact_publication_id: s[:pact_publication_ids])
|
73
|
-
elsif s[:pacticipant_version_id]
|
74
|
-
Sequel.&(consumer_id: s[:pacticipant_id], consumer_version_id: s[:pacticipant_version_id])
|
75
|
-
else
|
76
|
-
Sequel.&(consumer_id: s[:pacticipant_id])
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
def self.provider_and_maybe_provider_version_match_selector(s)
|
81
|
-
if s[:verification_ids]
|
82
|
-
Sequel.&(verification_id: s[:verification_ids])
|
83
|
-
elsif s[:pacticipant_version_id]
|
84
|
-
Sequel.&(provider_id: s[:pacticipant_id], provider_version_id: s[:pacticipant_version_id])
|
85
|
-
else
|
86
|
-
Sequel.&(provider_id: s[:pacticipant_id])
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
# if the pact for a consumer version has never been verified, it exists in the matrix as a row
|
91
|
-
# with a blank provider version id
|
92
|
-
def self.provider_verification_is_missing_for_matching_selector(s)
|
93
|
-
Sequel.&(provider_id: s[:pacticipant_id], provider_version_id: nil)
|
94
|
-
end
|
95
|
-
|
96
|
-
def self.provider_and_maybe_provider_version_match_any_selector_or_verification_is_missing(selectors)
|
97
|
-
selectors.collect { |s|
|
98
|
-
provider_and_maybe_provider_version_match_selector(s)
|
99
|
-
} + selectors.collect { |s|
|
100
|
-
provider_verification_is_missing_for_matching_selector(s)
|
101
|
-
}
|
102
|
-
end
|
103
|
-
|
104
|
-
# Some selecters are specified in the query, others are implied (when only one pacticipant is specified,
|
105
|
-
# the integrations are automatically worked out, and the selectors for these are of type :implied )
|
106
|
-
# When there are 3 pacticipants that each have dependencies on each other (A->B, A->C, B->C), the query
|
107
|
-
# to deploy C (implied A, implied B, specified C) was returning the A->B row because it matched the
|
108
|
-
# implied selectors as well.
|
109
|
-
# This extra filter makes sure that every row that is returned actually matches one of the specified
|
110
|
-
# selectors.
|
111
|
-
def self.either_consumer_or_provider_was_specified_in_query(selectors)
|
112
|
-
specified_pacticipant_ids = selectors.select{ |s| s[:type] == :specified }.collect{ |s| s[:pacticipant_id] }
|
113
|
-
Sequel.|({ consumer_id: specified_pacticipant_ids } , { provider_id: specified_pacticipant_ids })
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
def where_consumer_or_provider_is s
|
118
|
-
where{
|
119
|
-
Sequel.|(
|
120
|
-
s[:pacticipant_version_id] ? Sequel.&(consumer_id: s[:pacticipant_id], consumer_version_id: s[:pacticipant_version_id]) : Sequel.&(consumer_id: s[:pacticipant_id]),
|
121
|
-
s[:pacticipant_version_id] ? Sequel.&(provider_id: s[:pacticipant_id], provider_version_id: s[:pacticipant_version_id]) : Sequel.&(provider_id: s[:pacticipant_id])
|
122
|
-
)
|
123
|
-
}
|
124
|
-
end
|
125
|
-
|
126
|
-
def order_by_names_ascending_most_recent_first
|
127
|
-
order(
|
128
|
-
Sequel.asc(:consumer_name),
|
129
|
-
Sequel.desc(:consumer_version_order),
|
130
|
-
Sequel.desc(:pact_revision_number),
|
131
|
-
Sequel.asc(:provider_name),
|
132
|
-
Sequel.desc(:provider_version_order),
|
133
|
-
Sequel.desc(:verification_id))
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
# Temporary method while we transition from returning Hashes to return Matrix objects
|
138
|
-
# from the repository find methods
|
139
|
-
# Need to make the object act as a hash and an object
|
140
|
-
def [] key
|
141
|
-
if key == :provider_version_tags || key == :consumer_version_tags
|
142
|
-
send(key)
|
143
|
-
else
|
144
|
-
super
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
|
-
def summary
|
149
|
-
"#{consumer_name}#{consumer_version_number} #{provider_name}#{provider_version_number || '?'} (r#{pact_revision_number}n#{verification_number || '?'})"
|
150
|
-
end
|
151
|
-
|
152
|
-
def consumer
|
153
|
-
@consumer ||= Domain::Pacticipant.new(name: consumer_name).tap { |pacticipant| pacticipant.id = consumer_id }
|
154
|
-
end
|
155
|
-
|
156
|
-
def provider
|
157
|
-
@provider ||= Domain::Pacticipant.new(name: provider_name).tap { |pacticipant| pacticipant.id = provider_id }
|
158
|
-
end
|
159
|
-
|
160
|
-
def consumer_version
|
161
|
-
@consumer_version ||= OpenStruct.new(number: consumer_version_number, order: consumer_version_order, id: consumer_version_id, pacticipant: consumer)
|
162
|
-
end
|
163
|
-
|
164
|
-
def provider_version
|
165
|
-
if provider_version_number
|
166
|
-
@provider_version ||= OpenStruct.new(number: provider_version_number, order: provider_version_order, id: provider_version_id, pacticipant: provider)
|
167
|
-
end
|
168
|
-
end
|
169
|
-
|
170
|
-
def pact
|
171
|
-
@pact ||= OpenStruct.new(
|
172
|
-
consumer: consumer,
|
173
|
-
provider: provider,
|
174
|
-
consumer_version: consumer_version,
|
175
|
-
consumer_version_number: consumer_version_number,
|
176
|
-
created_at: pact_created_at,
|
177
|
-
revision_number: pact_revision_number,
|
178
|
-
pact_version_sha: pact_version_sha
|
179
|
-
)
|
180
|
-
end
|
181
|
-
|
182
|
-
def verification
|
183
|
-
if verification_executed_at
|
184
|
-
@latest_verification ||= OpenStruct.new(
|
185
|
-
id: verification_id,
|
186
|
-
success: success,
|
187
|
-
number: verification_number,
|
188
|
-
execution_date: verification_executed_at,
|
189
|
-
created_at: verification_executed_at,
|
190
|
-
provider_version_number: provider_version_number,
|
191
|
-
provider_version_order: provider_version_order,
|
192
|
-
build_url: verification_build_url,
|
193
|
-
provider_version: provider_version,
|
194
|
-
consumer_name: consumer_name,
|
195
|
-
provider_name: provider_name,
|
196
|
-
pact_version_sha: pact_version_sha
|
197
|
-
)
|
198
|
-
end
|
199
|
-
end
|
200
|
-
|
201
|
-
# Add logic for ignoring case
|
202
|
-
def <=> other
|
203
|
-
comparisons = [
|
204
|
-
compare_name_asc(consumer_name, other.consumer_name),
|
205
|
-
compare_number_desc(consumer_version_order, other.consumer_version_order),
|
206
|
-
compare_number_desc(pact_revision_number, other.pact_revision_number),
|
207
|
-
compare_name_asc(provider_name, other.provider_name),
|
208
|
-
compare_number_desc(provider_version_order, other.provider_version_order),
|
209
|
-
compare_number_desc(verification_id, other.verification_id)
|
210
|
-
]
|
211
|
-
|
212
|
-
comparisons.find{|c| c != 0 } || 0
|
213
|
-
end
|
214
|
-
|
215
|
-
def compare_name_asc name1, name2
|
216
|
-
name1 <=> name2
|
217
|
-
end
|
218
|
-
|
219
|
-
def to_s
|
220
|
-
"#{consumer_name} #{consumer_version_number} #{provider_name} #{provider_version_number} #{success}"
|
221
|
-
end
|
222
|
-
|
223
|
-
def compare_number_desc number1, number2
|
224
|
-
if number1 && number2
|
225
|
-
number2 <=> number1
|
226
|
-
elsif number1
|
227
|
-
1
|
228
|
-
else
|
229
|
-
-1
|
230
|
-
end
|
231
|
-
end
|
232
|
-
|
233
|
-
# For some reason, with MySQL, the success column value
|
234
|
-
# comes back as an integer rather than a boolean
|
235
|
-
# for the latest_matrix view (but not the matrix view!)
|
236
|
-
# Maybe something to do with the union?
|
237
|
-
# Haven't investigated as this is an easy enough fix.
|
238
|
-
def success
|
239
|
-
value = super
|
240
|
-
value.nil? ? nil : value == true || value == 1
|
241
|
-
end
|
242
|
-
|
243
|
-
def values
|
244
|
-
super.merge(success: success)
|
245
|
-
end
|
246
|
-
|
247
|
-
# Need to overwrite eql? from lib/sequel/model/base.rb
|
248
|
-
# because it uses @values instead of self.values
|
249
|
-
# so the success boolean/integer problem mentioned above
|
250
|
-
# screws things up
|
251
|
-
def eql?(obj)
|
252
|
-
(obj.class == model) && (obj.values == values)
|
253
|
-
end
|
254
|
-
|
255
|
-
def pacticipant_names
|
256
|
-
[consumer_name, provider_name]
|
257
|
-
end
|
258
|
-
|
259
|
-
def involves_pacticipant_with_name?(pacticipant_name)
|
260
|
-
pacticipant_name.include?(pacticipant_name)
|
261
|
-
end
|
262
|
-
end
|
263
|
-
end
|
264
|
-
end
|
265
|
-
|
266
|
-
# Table: matrix
|
267
|
-
# Columns:
|
268
|
-
# consumer_id | integer |
|
269
|
-
# consumer_name | text |
|
270
|
-
# consumer_version_id | integer |
|
271
|
-
# consumer_version_number | text |
|
272
|
-
# consumer_version_order | integer |
|
273
|
-
# pact_publication_id | integer |
|
274
|
-
# pact_version_id | integer |
|
275
|
-
# pact_version_sha | text |
|
276
|
-
# pact_revision_number | integer |
|
277
|
-
# pact_created_at | timestamp without time zone |
|
278
|
-
# provider_id | integer |
|
279
|
-
# provider_name | text |
|
280
|
-
# provider_version_id | integer |
|
281
|
-
# provider_version_number | text |
|
282
|
-
# provider_version_order | integer |
|
283
|
-
# verification_id | integer |
|
284
|
-
# success | boolean |
|
285
|
-
# verification_number | integer |
|
286
|
-
# verification_executed_at | timestamp without time zone |
|
287
|
-
# verification_build_url | text |
|