pact_broker 2.98.0 → 2.99.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/CHANGELOG.md +24 -0
 - data/docs/CONFIGURATION.md +11 -1
 - data/lib/pact_broker/api/middleware/http_debug_logs.rb +13 -7
 - 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/config/runtime_configuration.rb +2 -1
 - data/lib/pact_broker/config/runtime_configuration_database_methods.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 +2 -0
 - 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_dataset_module.rb +25 -0
 - data/lib/pact_broker/pacts/pact_publication_wip_dataset_module.rb +0 -15
 - data/lib/pact_broker/test/http_test_data_builder.rb +4 -2
 - data/lib/pact_broker/ui/views/groups/show.html.erb +2 -2
 - data/lib/pact_broker/version.rb +1 -1
 - metadata +3 -3
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: edd8be1bf717f3b98618f1f585146efa701f4833a9c2d8ba05eb395278bd435c
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 36c07bdd448edd40e623c0976ec65df4c2512ddf73ce400512e27d08f7a086d8
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 023ae6605034518c73da217fff6be8c6888bd7d56abcbf11895f18ec3eab9e32775ec574381473e626e1bca75bc3b132fd30fd755157e980d3e16dea9c125f4f
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 67d5dcb38a78a5e590ec961826951e32c4e391ad13eea43fbf57faa48de2c20212397cdb116b93c975ecdb576e7790112e6db16b43ba5c866af4c074c0370cd3
         
     | 
    
        data/CHANGELOG.md
    CHANGED
    
    | 
         @@ -1,3 +1,27 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            <a name="v2.99.0"></a>
         
     | 
| 
      
 2 
     | 
    
         
            +
            ### v2.99.0 (2022-05-13)
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            #### Features
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            * remove disable_use_branch_heads_for_latest_branch_pacts feature toggle	 ([5c6f1766](/../../commit/5c6f1766))
         
     | 
| 
      
 7 
     | 
    
         
            +
            * remove new_wip_calculation feature toggle	 ([add6cb08](/../../commit/add6cb08))
         
     | 
| 
      
 8 
     | 
    
         
            +
            * timeout long running pact content diff requests (#555)	 ([88abb2cf](/../../commit/88abb2cf))
         
     | 
| 
      
 9 
     | 
    
         
            +
            * change sql_log_level default from debug to none	 ([9f7aed46](/../../commit/9f7aed46))
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            #### Bug Fixes
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            * **ui**
         
     | 
| 
      
 14 
     | 
    
         
            +
              * fix unescaped pacticipant name and main branch in details and network pages	 ([b8b1d306](/../../commit/b8b1d306))
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
            * return a 400 when invalid JSON is used to create a version	 ([9af2cfaf](/../../commit/9af2cfaf))
         
     | 
| 
      
 17 
     | 
    
         
            +
            * only log API requests/responses, not web assets, when http_debug_logging_enabled is true	 ([1f232c08](/../../commit/1f232c08))
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            * **matrix**
         
     | 
| 
      
 20 
     | 
    
         
            +
              * fix performance issue when querying matrix with one selector	 ([3a08d128](/../../commit/3a08d128))
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
            * **pacts for verification**
         
     | 
| 
      
 23 
     | 
    
         
            +
              * return the pacts for the branch heads when using the branch selector	 ([6dac495e](/../../commit/6dac495e))
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
       1 
25 
     | 
    
         
             
            <a name="v2.98.0"></a>
         
     | 
| 
       2 
26 
     | 
    
         
             
            ### v2.98.0 (2022-03-29)
         
     | 
| 
       3 
27 
     | 
    
         | 
    
        data/docs/CONFIGURATION.md
    CHANGED
    
    | 
         @@ -57,6 +57,7 @@ While the default is `file` for the Ruby application, it is set to `stdout` on t 
     | 
|
| 
       57 
57 
     | 
    
         | 
| 
       58 
58 
     | 
    
         
             
            Enable this setting to print the entire request and response to the logs at debug level. Used for troubleshooting issues.
         
     | 
| 
       59 
59 
     | 
    
         
             
            Do not leave this on permanently, as it will have performance and security issues.
         
     | 
| 
      
 60 
     | 
    
         
            +
            Ensure the application [`log_level`](#log_level) is set to `debug` when this setting is enabled.
         
     | 
| 
       60 
61 
     | 
    
         | 
| 
       61 
62 
     | 
    
         
             
            **Supported versions:** From v2.98.0<br/>
         
     | 
| 
       62 
63 
     | 
    
         
             
            **Environment variable name:** `PACT_BROKER_HTTP_DEBUG_LOGGING_ENABLED`<br/>
         
     | 
| 
         @@ -156,7 +157,7 @@ To disable noisy SQL query logging when the application `log_level` is set to `d 
     | 
|
| 
       156 
157 
     | 
    
         | 
| 
       157 
158 
     | 
    
         
             
            **Environment variable name:** `PACT_BROKER_SQL_LOG_LEVEL`<br/>
         
     | 
| 
       158 
159 
     | 
    
         
             
            **YAML configuration key name:** `sql_log_level`<br/>
         
     | 
| 
       159 
     | 
    
         
            -
            **Default:** `debug 
     | 
| 
      
 160 
     | 
    
         
            +
            **Default:** From 2.99+, the default is `none`. In previous versions, the default is `debug`.<br/>
         
     | 
| 
       160 
161 
     | 
    
         
             
            **Allowed values:** `none`, `debug`, `info`, `warn`, `error`, `fatal`<br/>
         
     | 
| 
       161 
162 
     | 
    
         | 
| 
       162 
163 
     | 
    
         
             
            ### sql_log_warn_duration
         
     | 
| 
         @@ -654,6 +655,15 @@ with a unique version number. 
     | 
|
| 
       654 
655 
     | 
    
         
             
            **Allowed values:** `true`, `false`<br/>
         
     | 
| 
       655 
656 
     | 
    
         
             
            **More information:** https://docs.pact.io/versioning<br/>
         
     | 
| 
       656 
657 
     | 
    
         | 
| 
      
 658 
     | 
    
         
            +
            ### pact_content_diff_timeout
         
     | 
| 
      
 659 
     | 
    
         
            +
             
     | 
| 
      
 660 
     | 
    
         
            +
            The maximum amount of time in seconds to attempt to generate the diff between two pacts before aborting the request. This is required due to performance issues in the underlying diff generation code.
         
     | 
| 
      
 661 
     | 
    
         
            +
             
     | 
| 
      
 662 
     | 
    
         
            +
            **Supported versions:** From 2.99.0<br/>
         
     | 
| 
      
 663 
     | 
    
         
            +
            **Environment variable name:** `PACT_BROKER_PACT_CONTENT_DIFF_TIMEOUT`<br/>
         
     | 
| 
      
 664 
     | 
    
         
            +
            **YAML configuration key name:** `pact_content_diff_timeout`<br/>
         
     | 
| 
      
 665 
     | 
    
         
            +
            **Default:** `15`<br/>
         
     | 
| 
      
 666 
     | 
    
         
            +
             
     | 
| 
       657 
667 
     | 
    
         
             
            <br/>
         
     | 
| 
       658 
668 
     | 
    
         | 
| 
       659 
669 
     | 
    
         
             
            ## Miscellaneous
         
     | 
| 
         @@ -1,10 +1,12 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require "pact_broker/logging"
         
     | 
| 
      
 2 
     | 
    
         
            +
            require "rack/pact_broker/request_target"
         
     | 
| 
       2 
3 
     | 
    
         | 
| 
       3 
4 
     | 
    
         
             
            module PactBroker
         
     | 
| 
       4 
5 
     | 
    
         
             
              module Api
         
     | 
| 
       5 
6 
     | 
    
         
             
                module Middleware
         
     | 
| 
       6 
7 
     | 
    
         
             
                  class HttpDebugLogs
         
     | 
| 
       7 
8 
     | 
    
         
             
                    include PactBroker::Logging
         
     | 
| 
      
 9 
     | 
    
         
            +
                    include Rack::PactBroker::RequestTarget
         
     | 
| 
       8 
10 
     | 
    
         | 
| 
       9 
11 
     | 
    
         
             
                    EXCLUDE_HEADERS = ["puma.", "rack.", "pactbroker."]
         
     | 
| 
       10 
12 
     | 
    
         
             
                    RACK_SESSION = "rack.session"
         
     | 
| 
         @@ -15,13 +17,17 @@ module PactBroker 
     | 
|
| 
       15 
17 
     | 
    
         
             
                    end
         
     | 
| 
       16 
18 
     | 
    
         | 
| 
       17 
19 
     | 
    
         
             
                    def call(env)
         
     | 
| 
       18 
     | 
    
         
            -
                       
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
      
 20 
     | 
    
         
            +
                      if request_for_api?(env)
         
     | 
| 
      
 21 
     | 
    
         
            +
                        env_to_log = env.reject { | header, _ | header.start_with?(*EXCLUDE_HEADERS) }
         
     | 
| 
      
 22 
     | 
    
         
            +
                        env_to_log["rack.session"] = env["rack.session"].to_hash if env["rack.session"]
         
     | 
| 
      
 23 
     | 
    
         
            +
                        env_to_log["rack.input"] = request_body(env) if env["rack.input"]
         
     | 
| 
      
 24 
     | 
    
         
            +
                        logger.debug("env", payload: env_to_log)
         
     | 
| 
      
 25 
     | 
    
         
            +
                        status, headers, body = @app.call(env)
         
     | 
| 
      
 26 
     | 
    
         
            +
                        logger.debug("response", payload: { "status" => status, "headers" => headers, "body" => body })
         
     | 
| 
      
 27 
     | 
    
         
            +
                        [status, headers, body]
         
     | 
| 
      
 28 
     | 
    
         
            +
                      else
         
     | 
| 
      
 29 
     | 
    
         
            +
                        @app.call(env)
         
     | 
| 
      
 30 
     | 
    
         
            +
                      end
         
     | 
| 
       25 
31 
     | 
    
         
             
                    end
         
     | 
| 
       26 
32 
     | 
    
         | 
| 
       27 
33 
     | 
    
         
             
                    def request_body(env)
         
     | 
| 
         @@ -1,6 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require "pact_broker/api/resources/base_resource"
         
     | 
| 
       2 
2 
     | 
    
         
             
            require "pact_broker/pacts/pact_params"
         
     | 
| 
       3 
3 
     | 
    
         
             
            require "pact_broker/pacts/diff"
         
     | 
| 
      
 4 
     | 
    
         
            +
            require "timeout"
         
     | 
| 
       4 
5 
     | 
    
         | 
| 
       5 
6 
     | 
    
         
             
            module PactBroker
         
     | 
| 
       6 
7 
     | 
    
         
             
              module Api
         
     | 
| 
         @@ -19,8 +20,12 @@ module PactBroker 
     | 
|
| 
       19 
20 
     | 
    
         
             
                    end
         
     | 
| 
       20 
21 
     | 
    
         | 
| 
       21 
22 
     | 
    
         
             
                    def to_text
         
     | 
| 
       22 
     | 
    
         
            -
                       
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
      
 23 
     | 
    
         
            +
                      Timeout::timeout(PactBroker.configuration.pact_content_diff_timeout) do
         
     | 
| 
      
 24 
     | 
    
         
            +
                        output = PactBroker::Pacts::Diff.new.process pact_params.merge(base_url: base_url), comparison_pact_params, raw: false
         
     | 
| 
      
 25 
     | 
    
         
            +
                        response.body = output
         
     | 
| 
      
 26 
     | 
    
         
            +
                      end
         
     | 
| 
      
 27 
     | 
    
         
            +
                    rescue Timeout::Error
         
     | 
| 
      
 28 
     | 
    
         
            +
                      408
         
     | 
| 
       24 
29 
     | 
    
         
             
                    end
         
     | 
| 
       25 
30 
     | 
    
         | 
| 
       26 
31 
     | 
    
         
             
                    def pact
         
     | 
| 
         @@ -71,7 +71,8 @@ module PactBroker 
     | 
|
| 
       71 
71 
     | 
    
         
             
                    badge_provider_mode: :redirect,
         
     | 
| 
       72 
72 
     | 
    
         
             
                    enable_public_badge_access: false,
         
     | 
| 
       73 
73 
     | 
    
         
             
                    shields_io_base_url: "https://img.shields.io",
         
     | 
| 
       74 
     | 
    
         
            -
                    use_case_sensitive_resource_names: true
         
     | 
| 
      
 74 
     | 
    
         
            +
                    use_case_sensitive_resource_names: true,
         
     | 
| 
      
 75 
     | 
    
         
            +
                    pact_content_diff_timeout: 15
         
     | 
| 
       75 
76 
     | 
    
         
             
                  )
         
     | 
| 
       76 
77 
     | 
    
         | 
| 
       77 
78 
     | 
    
         
             
                  # domain attributes
         
     | 
| 
         @@ -17,15 +17,19 @@ module PactBroker 
     | 
|
| 
       17 
17 
     | 
    
         
             
                    Sequel[:p][:created_at].as(:consumer_version_created_at),
         
     | 
| 
       18 
18 
     | 
    
         
             
                    Sequel[:p][:id].as(:pact_order)
         
     | 
| 
       19 
19 
     | 
    
         
             
                  ]
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
       20 
21 
     | 
    
         
             
                  VERIFICATION_COLUMNS = [
         
     | 
| 
       21 
22 
     | 
    
         
             
                    Sequel[:v][:id].as(:verification_id),
         
     | 
| 
       22 
23 
     | 
    
         
             
                    Sequel[:v][:provider_version_id],
         
     | 
| 
       23 
24 
     | 
    
         
             
                    Sequel[:v][:created_at].as(:provider_version_created_at)
         
     | 
| 
       24 
25 
     | 
    
         
             
                  ]
         
     | 
| 
       25 
26 
     | 
    
         | 
| 
      
 27 
     | 
    
         
            +
                  JOINED_VERIFICATION_COLUMNS = [:id, :pact_version_id, :provider_id, :provider_version_id, :created_at]
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
       26 
29 
     | 
    
         
             
                  ALL_COLUMNS = PACT_COLUMNS + VERIFICATION_COLUMNS
         
     | 
| 
       27 
30 
     | 
    
         | 
| 
       28 
31 
     | 
    
         
             
                  SELECT_ALL_COLUMN_ARGS = [:select_all_columns] + ALL_COLUMNS
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
       29 
33 
     | 
    
         
             
                  dataset_module do
         
     | 
| 
       30 
34 
     | 
    
         
             
                    select(*SELECT_ALL_COLUMN_ARGS)
         
     | 
| 
       31 
35 
     | 
    
         | 
| 
         @@ -33,9 +37,23 @@ module PactBroker 
     | 
|
| 
       33 
37 
     | 
    
         
             
                      left_outer_join(:verifications, P_V_JOIN, { table_alias: :v } )
         
     | 
| 
       34 
38 
     | 
    
         
             
                    end
         
     | 
| 
       35 
39 
     | 
    
         | 
| 
      
 40 
     | 
    
         
            +
                    def inner_join_verifications
         
     | 
| 
      
 41 
     | 
    
         
            +
                      join(:verifications, P_V_JOIN, { table_alias: :v } )
         
     | 
| 
      
 42 
     | 
    
         
            +
                    end
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
                    def inner_join_verifications_matching_one_selector_provider_or_provider_version(query_ids)
         
     | 
| 
      
 45 
     | 
    
         
            +
                      verifications = db[:verifications]
         
     | 
| 
      
 46 
     | 
    
         
            +
                        .select(*JOINED_VERIFICATION_COLUMNS)
         
     | 
| 
      
 47 
     | 
    
         
            +
                        .where {
         
     | 
| 
      
 48 
     | 
    
         
            +
                          QueryBuilder.provider_or_provider_version_matches(query_ids)
         
     | 
| 
      
 49 
     | 
    
         
            +
                        }
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
                      join(verifications, P_V_JOIN, { table_alias: :v } )
         
     | 
| 
      
 52 
     | 
    
         
            +
                    end
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
       36 
54 
     | 
    
         
             
                    def verifications_for(query_ids)
         
     | 
| 
       37 
55 
     | 
    
         
             
                      db[:verifications]
         
     | 
| 
       38 
     | 
    
         
            -
                        .select( 
     | 
| 
      
 56 
     | 
    
         
            +
                        .select(*JOINED_VERIFICATION_COLUMNS)
         
     | 
| 
       39 
57 
     | 
    
         
             
                        .where {
         
     | 
| 
       40 
58 
     | 
    
         
             
                          Sequel.&(
         
     | 
| 
       41 
59 
     | 
    
         
             
                            QueryBuilder.consumer_in_pacticipant_ids(query_ids),
         
     | 
| 
         @@ -1,9 +1,9 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
       2 
1 
     | 
    
         
             
            # Represents the integration relationship between a consumer and a provider in the context
         
     | 
| 
       3 
2 
     | 
    
         
             
            # of a matrix or can-i-deploy query.
         
     | 
| 
       4 
     | 
    
         
            -
            # If the required flag is set, then one of the pacticipants  
     | 
| 
       5 
     | 
    
         
            -
            # requires the provider.  
     | 
| 
       6 
     | 
    
         
            -
            # integration with a consumer.
         
     | 
| 
      
 3 
     | 
    
         
            +
            # If the required flag is set, then one of the pacticipants specified in the matrix query
         
     | 
| 
      
 4 
     | 
    
         
            +
            # is a consumer and it requires the provider to be already deployed. An integration would not be required if a provider
         
     | 
| 
      
 5 
     | 
    
         
            +
            # was specified, and it had an integration with a consumer, but that consumer wasn't deployed yet.
         
     | 
| 
      
 6 
     | 
    
         
            +
            #
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
8 
     | 
    
         
             
            module PactBroker
         
     | 
| 
       9 
9 
     | 
    
         
             
              module Matrix
         
     | 
| 
         @@ -11,7 +11,7 @@ module PactBroker 
     | 
|
| 
       11 
11 
     | 
    
         | 
| 
       12 
12 
     | 
    
         
             
                  attr_reader :consumer_name, :consumer_id, :provider_name, :provider_id
         
     | 
| 
       13 
13 
     | 
    
         | 
| 
       14 
     | 
    
         
            -
                  def initialize 
     | 
| 
      
 14 
     | 
    
         
            +
                  def initialize(consumer_id, consumer_name, provider_id, provider_name, required)
         
     | 
| 
       15 
15 
     | 
    
         
             
                    @consumer_id = consumer_id
         
     | 
| 
       16 
16 
     | 
    
         
             
                    @consumer_name = consumer_name
         
     | 
| 
       17 
17 
     | 
    
         
             
                    @provider_id = provider_id
         
     | 
| 
         @@ -11,6 +11,14 @@ require "pact_broker/pacts/pact_publication" 
     | 
|
| 
       11 
11 
     | 
    
         
             
            require "pact_broker/tags/tag_with_latest_flag"
         
     | 
| 
       12 
12 
     | 
    
         
             
            require "pact_broker/matrix/query_ids"
         
     | 
| 
       13 
13 
     | 
    
         | 
| 
      
 14 
     | 
    
         
            +
            # The PactBroker::Matrix::QuickRow represents a row in the table that is created when
         
     | 
| 
      
 15 
     | 
    
         
            +
            # the consumer versions are joined to the provider versions via the pacts and verifications tables,
         
     | 
| 
      
 16 
     | 
    
         
            +
            # aka "The Matrix". The difference between this class and the EveryRow class is that
         
     | 
| 
      
 17 
     | 
    
         
            +
            # the EveryRow class includes results for overridden pact verisons and verifications (used only when there is no latestby
         
     | 
| 
      
 18 
     | 
    
         
            +
            # set in the matrix query), where as the QuickRow class does not.
         
     | 
| 
      
 19 
     | 
    
         
            +
            # It is called the QuickRow because the initial implementation was called the Row, and this is an optimised
         
     | 
| 
      
 20 
     | 
    
         
            +
            # version. It needs to be renamed back to Row now that the old Row class has been deleted.
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
       14 
22 
     | 
    
         
             
            # The difference between `join_verifications_for` and `join_verifications` is that
         
     | 
| 
       15 
23 
     | 
    
         
             
            # the left outer join is done on a pre-filtered dataset in `join_verifications_for`,
         
     | 
| 
       16 
24 
     | 
    
         
             
            # so that we get a row with null verification fields for a pact that has been verified
         
     | 
| 
         @@ -19,6 +27,7 @@ require "pact_broker/matrix/query_ids" 
     | 
|
| 
       19 
27 
     | 
    
         | 
| 
       20 
28 
     | 
    
         
             
            module PactBroker
         
     | 
| 
       21 
29 
     | 
    
         
             
              module Matrix
         
     | 
| 
      
 30 
     | 
    
         
            +
                # TODO rename this to just Row
         
     | 
| 
       22 
31 
     | 
    
         
             
                # rubocop: disable Metrics/ClassLength
         
     | 
| 
       23 
32 
     | 
    
         
             
                class QuickRow < Sequel::Model(Sequel.as(:latest_pact_publication_ids_for_consumer_versions, :p))
         
     | 
| 
       24 
33 
     | 
    
         | 
| 
         @@ -45,6 +54,15 @@ module PactBroker 
     | 
|
| 
       45 
54 
     | 
    
         
             
                    Sequel[:v][:verification_id],
         
     | 
| 
       46 
55 
     | 
    
         
             
                    Sequel[:v][:created_at].as(:provider_version_created_at)
         
     | 
| 
       47 
56 
     | 
    
         
             
                  ]
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
                  JOINED_VERIFICATION_COLUMNS = [
         
     | 
| 
      
 59 
     | 
    
         
            +
                    :verification_id,
         
     | 
| 
      
 60 
     | 
    
         
            +
                    :provider_version_id,
         
     | 
| 
      
 61 
     | 
    
         
            +
                    :pact_version_id,
         
     | 
| 
      
 62 
     | 
    
         
            +
                    :provider_id,
         
     | 
| 
      
 63 
     | 
    
         
            +
                    :created_at
         
     | 
| 
      
 64 
     | 
    
         
            +
                  ]
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
       48 
66 
     | 
    
         
             
                  LAST_ACTION_DATE = Sequel.lit("CASE WHEN (provider_version_created_at IS NOT NULL AND provider_version_created_at > consumer_version_created_at) THEN provider_version_created_at ELSE consumer_version_created_at END").as(:last_action_date)
         
     | 
| 
       49 
67 
     | 
    
         | 
| 
       50 
68 
     | 
    
         
             
                  ALL_COLUMNS = PACT_COLUMNS + VERIFICATION_COLUMNS
         
     | 
| 
         @@ -146,10 +164,15 @@ module PactBroker 
     | 
|
| 
       146 
164 
     | 
    
         
             
                    # When we have one selector, we need to join ALL the verifications to find out
         
     | 
| 
       147 
165 
     | 
    
         
             
                    # what integrations exist
         
     | 
| 
       148 
166 
     | 
    
         
             
                    def matching_one_selector(selectors)
         
     | 
| 
       149 
     | 
    
         
            -
                       
     | 
| 
      
 167 
     | 
    
         
            +
                      query_ids = QueryIds.from_selectors(selectors)
         
     | 
| 
      
 168 
     | 
    
         
            +
                      rows_where_selector_matches_consumer_cols = join_verifications
         
     | 
| 
       150 
169 
     | 
    
         
             
                        .where {
         
     | 
| 
       151 
     | 
    
         
            -
                          QueryBuilder. 
     | 
| 
      
 170 
     | 
    
         
            +
                          QueryBuilder.consumer_or_consumer_version_matches(query_ids, :p)
         
     | 
| 
       152 
171 
     | 
    
         
             
                        }
         
     | 
| 
      
 172 
     | 
    
         
            +
             
     | 
| 
      
 173 
     | 
    
         
            +
                      rows_where_selector_matches_provider_cols = inner_join_verifications_matching_one_selector_provider_or_provider_version(query_ids)
         
     | 
| 
      
 174 
     | 
    
         
            +
             
     | 
| 
      
 175 
     | 
    
         
            +
                      rows_where_selector_matches_consumer_cols.union(rows_where_selector_matches_provider_cols)
         
     | 
| 
       153 
176 
     | 
    
         
             
                    end
         
     | 
| 
       154 
177 
     | 
    
         | 
| 
       155 
178 
     | 
    
         
             
                    def pacticipant_ids_matching_one_selector_optimised(selectors)
         
     | 
| 
         @@ -229,9 +252,19 @@ module PactBroker 
     | 
|
| 
       229 
252 
     | 
    
         
             
                      left_outer_join(verifications_for(query_ids), LP_LV_JOIN, { table_alias: :v } )
         
     | 
| 
       230 
253 
     | 
    
         
             
                    end
         
     | 
| 
       231 
254 
     | 
    
         | 
| 
      
 255 
     | 
    
         
            +
                    def inner_join_verifications_matching_one_selector_provider_or_provider_version(query_ids)
         
     | 
| 
      
 256 
     | 
    
         
            +
                      verifications = db[LV]
         
     | 
| 
      
 257 
     | 
    
         
            +
                        .select(*JOINED_VERIFICATION_COLUMNS)
         
     | 
| 
      
 258 
     | 
    
         
            +
                        .where {
         
     | 
| 
      
 259 
     | 
    
         
            +
                          QueryBuilder.provider_or_provider_version_matches(query_ids)
         
     | 
| 
      
 260 
     | 
    
         
            +
                        }
         
     | 
| 
      
 261 
     | 
    
         
            +
             
     | 
| 
      
 262 
     | 
    
         
            +
                      join(verifications, LP_LV_JOIN, { table_alias: :v } )
         
     | 
| 
      
 263 
     | 
    
         
            +
                    end
         
     | 
| 
      
 264 
     | 
    
         
            +
             
     | 
| 
       232 
265 
     | 
    
         
             
                    def verifications_for(query_ids)
         
     | 
| 
       233 
266 
     | 
    
         
             
                      db[LV]
         
     | 
| 
       234 
     | 
    
         
            -
                        .select( 
     | 
| 
      
 267 
     | 
    
         
            +
                        .select(*JOINED_VERIFICATION_COLUMNS)
         
     | 
| 
       235 
268 
     | 
    
         
             
                        .where {
         
     | 
| 
       236 
269 
     | 
    
         
             
                          Sequel.&(
         
     | 
| 
       237 
270 
     | 
    
         
             
                            QueryBuilder.consumer_in_pacticipant_ids(query_ids),
         
     | 
| 
         @@ -123,6 +123,8 @@ module PactBroker 
     | 
|
| 
       123 
123 
     | 
    
         
             
                    end
         
     | 
| 
       124 
124 
     | 
    
         
             
                  end
         
     | 
| 
       125 
125 
     | 
    
         | 
| 
      
 126 
     | 
    
         
            +
                  # Why does the consumer equivalent of this method use the QuickRow distinct_integrations_for_selector_as_consumer
         
     | 
| 
      
 127 
     | 
    
         
            +
                  # while this method uses the Integration?
         
     | 
| 
       126 
128 
     | 
    
         
             
                  def integrations_where_specified_selector_is_provider(resolved_specified_selectors)
         
     | 
| 
       127 
129 
     | 
    
         
             
                    integrations_involving_specified_providers = PactBroker::Integrations::Integration
         
     | 
| 
       128 
130 
     | 
    
         
             
                                                                  .where(provider_id: resolved_specified_selectors.collect(&:pacticipant_id))
         
     | 
| 
         @@ -32,7 +32,10 @@ module PactBroker 
     | 
|
| 
       32 
32 
     | 
    
         | 
| 
       33 
33 
     | 
    
         
             
                      pact_publications.each do | pact_publication |
         
     | 
| 
       34 
34 
     | 
    
         
             
                        pact_publication.consumer_version_tags.collect(&:name).sort.each do | tag_name |
         
     | 
| 
       35 
     | 
    
         
            -
                           
     | 
| 
      
 35 
     | 
    
         
            +
                          # Not sure how this can ever be nil, but a PF error suggests that it has happend. Maybe a timing issue?
         
     | 
| 
      
 36 
     | 
    
         
            +
                          if head_pact_publications_by_tag[tag_name]
         
     | 
| 
      
 37 
     | 
    
         
            +
                            pact_publication.associations[:head_pact_publications_for_tags] << head_pact_publications_by_tag[tag_name]
         
     | 
| 
      
 38 
     | 
    
         
            +
                          end
         
     | 
| 
       36 
39 
     | 
    
         
             
                        end
         
     | 
| 
       37 
40 
     | 
    
         
             
                      end
         
     | 
| 
       38 
41 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -111,7 +111,32 @@ module PactBroker 
     | 
|
| 
       111 
111 
     | 
    
         
             
                      .limit(1)
         
     | 
| 
       112 
112 
     | 
    
         
             
                  end
         
     | 
| 
       113 
113 
     | 
    
         | 
| 
      
 114 
     | 
    
         
            +
                  # Return the pacts (if they exist) for the branch heads.
         
     | 
| 
      
 115 
     | 
    
         
            +
                  # This uses the new logic of finding the branch head and returning any associated pacts,
         
     | 
| 
      
 116 
     | 
    
         
            +
                  # rather than the old logic of returning the pact for the latest version
         
     | 
| 
      
 117 
     | 
    
         
            +
                  # on the branch that had a pact.
         
     | 
| 
      
 118 
     | 
    
         
            +
                  def for_branch_heads(branch_name)
         
     | 
| 
      
 119 
     | 
    
         
            +
                    branch_head_join = {
         
     | 
| 
      
 120 
     | 
    
         
            +
                      Sequel[:pact_publications][:consumer_version_id] => Sequel[:branch_heads][:version_id],
         
     | 
| 
      
 121 
     | 
    
         
            +
                    }
         
     | 
| 
      
 122 
     | 
    
         
            +
             
     | 
| 
      
 123 
     | 
    
         
            +
                    base_query = self
         
     | 
| 
      
 124 
     | 
    
         
            +
                    if no_columns_selected?
         
     | 
| 
      
 125 
     | 
    
         
            +
                      base_query = base_query.select_all_qualified.select_append(Sequel[:branch_heads][:branch_name].as(:branch_name))
         
     | 
| 
      
 126 
     | 
    
         
            +
                    end
         
     | 
| 
      
 127 
     | 
    
         
            +
             
     | 
| 
      
 128 
     | 
    
         
            +
                    base_query
         
     | 
| 
      
 129 
     | 
    
         
            +
                      .join(:branch_heads, branch_head_join) do
         
     | 
| 
      
 130 
     | 
    
         
            +
                        name_like(Sequel[:branch_heads][:branch_name], branch_name)
         
     | 
| 
      
 131 
     | 
    
         
            +
                      end
         
     | 
| 
      
 132 
     | 
    
         
            +
                      .remove_overridden_revisions_from_complete_query
         
     | 
| 
      
 133 
     | 
    
         
            +
                  end
         
     | 
| 
      
 134 
     | 
    
         
            +
             
     | 
| 
       114 
135 
     | 
    
         
             
                  def latest_for_consumer_branch(branch_name)
         
     | 
| 
      
 136 
     | 
    
         
            +
                    for_branch_heads(branch_name)
         
     | 
| 
      
 137 
     | 
    
         
            +
                  end
         
     | 
| 
      
 138 
     | 
    
         
            +
             
     | 
| 
      
 139 
     | 
    
         
            +
                  def old_latest_for_consumer_branch(branch_name)
         
     | 
| 
       115 
140 
     | 
    
         
             
                    branch_versions_join = {
         
     | 
| 
       116 
141 
     | 
    
         
             
                      Sequel[:pact_publications][:consumer_version_id] => Sequel[:branch_versions][:version_id]
         
     | 
| 
       117 
142 
     | 
    
         
             
                    }
         
     | 
| 
         @@ -47,21 +47,6 @@ module PactBroker 
     | 
|
| 
       47 
47 
     | 
    
         
             
                  end
         
     | 
| 
       48 
48 
     | 
    
         | 
| 
       49 
49 
     | 
    
         
             
                  def successfully_verified_by_provider_another_tag_before_this_tag_first_created(provider_id, provider_tag)
         
     | 
| 
       50 
     | 
    
         
            -
                    return new_successfully_verified_by_provider_another_tag_before_this_tag_first_created(provider_id, provider_tag) if PactBroker.feature_enabled?(:new_wip_calculation)
         
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
       52 
     | 
    
         
            -
                    first_tag_with_name = PactBroker::Domain::Tag.where(pacticipant_id: provider_id, name: provider_tag).order(:created_at).first
         
     | 
| 
       53 
     | 
    
         
            -
                    from_self(alias: :pp)
         
     | 
| 
       54 
     | 
    
         
            -
                      .select(Sequel[:pp].*)
         
     | 
| 
       55 
     | 
    
         
            -
                      .where(Sequel[:pp][:provider_id] => provider_id)
         
     | 
| 
       56 
     | 
    
         
            -
                      .join_successful_non_wip_verifications_for_provider_id(provider_id)
         
     | 
| 
       57 
     | 
    
         
            -
                      .join_provider_version_tags do
         
     | 
| 
       58 
     | 
    
         
            -
                        Sequel.lit("provider_tags.name != ?", provider_tag)
         
     | 
| 
       59 
     | 
    
         
            -
                      end
         
     | 
| 
       60 
     | 
    
         
            -
                      .verified_before_creation_date_of(first_tag_with_name)
         
     | 
| 
       61 
     | 
    
         
            -
                      .distinct
         
     | 
| 
       62 
     | 
    
         
            -
                  end
         
     | 
| 
       63 
     | 
    
         
            -
             
     | 
| 
       64 
     | 
    
         
            -
                  def new_successfully_verified_by_provider_another_tag_before_this_tag_first_created(provider_id, provider_tag)
         
     | 
| 
       65 
50 
     | 
    
         
             
                    first_tag_with_name = PactBroker::Domain::Tag.where(pacticipant_id: provider_id, name: provider_tag).order(:created_at).first
         
     | 
| 
       66 
51 
     | 
    
         | 
| 
       67 
52 
     | 
    
         
             
                    pact_version_provider_tag_verifications_join = {
         
     | 
| 
         @@ -57,6 +57,8 @@ module PactBroker 
     | 
|
| 
       57 
57 
     | 
    
         | 
| 
       58 
58 
     | 
    
         
             
                  def create_version(pacticipant:, version:, branch: nil)
         
     | 
| 
       59 
59 
     | 
    
         
             
                    if branch
         
     | 
| 
      
 60 
     | 
    
         
            +
                      puts "Adding #{pacticipant} version #{version} to branch #{branch}"
         
     | 
| 
      
 61 
     | 
    
         
            +
                      puts ""
         
     | 
| 
       60 
62 
     | 
    
         
             
                      client.put("pacticipants/#{encode(pacticipant)}/branches/#{encode(branch)}/versions/#{encode(version)}", {}).tap { |response| check_for_error(response) }
         
     | 
| 
       61 
63 
     | 
    
         
             
                    else
         
     | 
| 
       62 
64 
     | 
    
         
             
                      client.put("pacticipants/#{encode(pacticipant)}/versions/#{encode(version)}").tap { |response| check_for_error(response) }
         
     | 
| 
         @@ -80,7 +82,7 @@ module PactBroker 
     | 
|
| 
       80 
82 
     | 
    
         
             
                      available_environments = version_body["_links"]["pb:record-deployment"].collect{ | relation | relation["name"]}.join
         
     | 
| 
       81 
83 
     | 
    
         
             
                      puts "Environment with name #{environment_name} not found. Available environments: #{available_environments}"
         
     | 
| 
       82 
84 
     | 
    
         
             
                    else
         
     | 
| 
       83 
     | 
    
         
            -
                      client.post(environment_relation["href"] 
     | 
| 
      
 85 
     | 
    
         
            +
                      client.post(environment_relation["href"]).tap { |response| check_for_error(response) }
         
     | 
| 
       84 
86 
     | 
    
         
             
                    end
         
     | 
| 
       85 
87 
     | 
    
         | 
| 
       86 
88 
     | 
    
         
             
                    separate
         
     | 
| 
         @@ -91,7 +93,7 @@ module PactBroker 
     | 
|
| 
       91 
93 
     | 
    
         
             
                    puts "Recording release of #{pacticipant} version #{version} to #{environment_name}"
         
     | 
| 
       92 
94 
     | 
    
         
             
                    version_body = client.get("/pacticipants/#{encode(pacticipant)}/versions/#{encode(version)}").tap { |response| check_for_error(response) }.body
         
     | 
| 
       93 
95 
     | 
    
         
             
                    environment_relation = version_body["_links"]["pb:record-release"].find { |relation| relation["name"] == environment_name }
         
     | 
| 
       94 
     | 
    
         
            -
                    client.post(environment_relation["href"] 
     | 
| 
      
 96 
     | 
    
         
            +
                    client.post(environment_relation["href"]).tap { |response| check_for_error(response) }
         
     | 
| 
       95 
97 
     | 
    
         
             
                    separate
         
     | 
| 
       96 
98 
     | 
    
         
             
                    self
         
     | 
| 
       97 
99 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -6,7 +6,7 @@ 
     | 
|
| 
       6 
6 
     | 
    
         
             
            <html lang="en">
         
     | 
| 
       7 
7 
     | 
    
         
             
            <head>
         
     | 
| 
       8 
8 
     | 
    
         
             
            <meta charset="utf-8">
         
     | 
| 
       9 
     | 
    
         
            -
            <title><%= pacticipant_name %></title>
         
     | 
| 
      
 9 
     | 
    
         
            +
            <title><%= escape_html(pacticipant_name) %></title>
         
     | 
| 
       10 
10 
     | 
    
         
             
            <link rel='shortcut icon' href='<%= base_url %>/favicon.ico' type='image/x-icon'/>
         
     | 
| 
       11 
11 
     | 
    
         
             
            <meta name="viewport" content="width=device-width, initial-scale=1.0">
         
     | 
| 
       12 
12 
     | 
    
         
             
            <meta name="description" content="">
         
     | 
| 
         @@ -69,7 +69,7 @@ svg{ 
     | 
|
| 
       69 
69 
     | 
    
         
             
                    Main branch:
         
     | 
| 
       70 
70 
     | 
    
         
             
                  </div>
         
     | 
| 
       71 
71 
     | 
    
         
             
                  <div class="col col-md-6">
         
     | 
| 
       72 
     | 
    
         
            -
                    <%= pacticipant.main_branch %>
         
     | 
| 
      
 72 
     | 
    
         
            +
                    <%= escape_html(pacticipant.main_branch) %>
         
     | 
| 
       73 
73 
     | 
    
         
             
                  </div>
         
     | 
| 
       74 
74 
     | 
    
         
             
                </div>
         
     | 
| 
       75 
75 
     | 
    
         
             
                <div class="row">
         
     | 
    
        data/lib/pact_broker/version.rb
    CHANGED
    
    
    
        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
         
     | 
| 
         @@ -1222,7 +1222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       1222 
1222 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       1223 
1223 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       1224 
1224 
     | 
    
         
             
            requirements: []
         
     | 
| 
       1225 
     | 
    
         
            -
            rubygems_version: 3.3. 
     | 
| 
      
 1225 
     | 
    
         
            +
            rubygems_version: 3.3.13
         
     | 
| 
       1226 
1226 
     | 
    
         
             
            signing_key:
         
     | 
| 
       1227 
1227 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       1228 
1228 
     | 
    
         
             
            summary: See description
         
     |