Module: PactBroker::Pacts::PactPublicationWipDatasetModule

Defined in:
lib/pact_broker/pacts/pact_publication_wip_dataset_module.rb

Defined Under Namespace

Classes: VerificationForWipCalculations

Instance Method Summary collapse

Instance Method Details

#successfully_verified_by_provider_another_branch_before_this_branch_first_created(provider_id, provider_version_branch) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/pact_broker/pacts/pact_publication_wip_dataset_module.rb', line 61

def successfully_verified_by_provider_another_branch_before_this_branch_first_created(provider_id, provider_version_branch)
  first_version_for_branch = PactBroker::Domain::Version.first_for_pacticipant_id_and_branch(provider_id, provider_version_branch)

  successful_verifications = VerificationForWipCalculations
                               .select(:pact_version_id)
                               .distinct
                               .successful_non_wip_by_provider(provider_id)
                               .join_branch_versions_excluding_branch(provider_id, provider_version_branch)
                               .verified_before_creation_date_of(first_version_for_branch)

  from_self(alias: :pp)
    .select(Sequel[:pp].*)
    .join(successful_verifications, { Sequel[:pp][:pact_version_id] => Sequel[:v][:pact_version_id] }, { table_alias: :v })
end

#successfully_verified_by_provider_another_tag_before_this_tag_first_created(provider_id, provider_tag) ⇒ Object



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/pact_broker/pacts/pact_publication_wip_dataset_module.rb', line 89

def successfully_verified_by_provider_another_tag_before_this_tag_first_created(provider_id, provider_tag)
  first_tag_with_name = PactBroker::Domain::Tag.where(pacticipant_id: provider_id, name: provider_tag).order(:created_at).first

  pact_version_provider_tag_verifications_join = {
    Sequel[:sv][:pact_version_id] => Sequel[:pp][:pact_version_id],
    Sequel[:sv][:wip] => false
  }

  created_at_criteria = if first_tag_with_name
                          Sequel.lit("sv.execution_date < ?", first_tag_with_name.created_at)
                        else
                          Sequel.lit("1 = 1")
                        end

  from_self(alias: :pp)
    .select(Sequel[:pp].*)
    .where(Sequel[:pp][:provider_id] => provider_id)
    .join(:pact_version_provider_tag_successful_verifications, pact_version_provider_tag_verifications_join, { table_alias: :sv }) do
      Sequel.&(
        Sequel.lit("sv.provider_version_tag_name NOT IN (?)", provider_tag),
        created_at_criteria
      )
    end
    .distinct
end

#successfully_verified_by_provider_branch_when_not_wip(provider_id, provider_version_branch) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/pact_broker/pacts/pact_publication_wip_dataset_module.rb', line 47

def successfully_verified_by_provider_branch_when_not_wip(provider_id, provider_version_branch)
  successful_verifications = VerificationForWipCalculations
                               .select(:pact_version_id)
                               .distinct
                               .successful_non_wip_by_provider(provider_id)
                               .join_provider_versions_for_provider_id_and_branch(provider_id, provider_version_branch)


  from_self(alias: :pp)
    .select(Sequel[:pp].*)
    .distinct
    .join(successful_verifications, { Sequel[:pp][:pact_version_id] => Sequel[:v][:pact_version_id] }, { table_alias: :v })
end

#successfully_verified_by_provider_tag_when_not_wip(provider_tag) ⇒ Object



76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/pact_broker/pacts/pact_publication_wip_dataset_module.rb', line 76

def successfully_verified_by_provider_tag_when_not_wip(provider_tag)
  pact_version_provider_tag_verifications_join = {
    Sequel[:sv][:pact_version_id] => Sequel[:pp][:pact_version_id],
    Sequel[:sv][:provider_version_tag_name] => provider_tag,
    Sequel[:sv][:wip] => false
  }

  from_self(alias: :pp)
    .select(Sequel[:pp].*)
    .join(:pact_version_provider_tag_successful_verifications, pact_version_provider_tag_verifications_join, { table_alias: :sv })
    .distinct
end