-
-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: updating pending and wip logic to exclude pacts already verifie…
…d by another branch before the specified branch was created (#432) * feat: keep pact not-pending if it has a successful verification from another branch from before this branch was created * feat: update WIP logic to exclude pacts already verified successfully by other branches * feat: update WIP logic to exclude pacts already verified successfully by other branches (by version branch)
- Loading branch information
Showing
16 changed files
with
583 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 106 additions & 0 deletions
106
lib/pact_broker/pacts/pact_publication_wip_dataset_module.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
module PactBroker | ||
module Pacts | ||
module PactPublicationWipDatasetModule | ||
def successfully_verified_by_provider_branch_when_not_wip(provider_id, provider_version_branch) | ||
from_self(alias: :pp) | ||
.select(Sequel[:pp].*) | ||
.where(Sequel[:pp][:provider_id] => provider_id) | ||
.join_successful_non_wip_verifications_for_provider_id(provider_id) | ||
.join_provider_versions_for_provider_id_and_branch(provider_id, provider_version_branch) | ||
.distinct | ||
end | ||
|
||
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) | ||
|
||
from_self(alias: :pp) | ||
.select(Sequel[:pp].*) | ||
.join_successful_non_wip_verifications_for_provider_id(provider_id) | ||
.join_provider_versions_for_provider_id(provider_id) do | ||
Sequel.lit('provider_versions.branch != ?', provider_version_branch) | ||
end | ||
.where(Sequel[:pp][:provider_id] => provider_id) | ||
.verified_before_creation_date_of(first_version_for_branch) | ||
.distinct | ||
end | ||
|
||
def successfully_verified_by_provider_tag_when_not_wip(provider_id, provider_tag) | ||
from_self(alias: :pp) | ||
.select(Sequel[:pp].*) | ||
.where(Sequel[:pp][:provider_id] => provider_id) | ||
.join_successful_non_wip_verifications_for_provider_id(provider_id) | ||
.join_provider_version_tags_for_tag(provider_tag) | ||
.distinct | ||
end | ||
|
||
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 | ||
from_self(alias: :pp) | ||
.select(Sequel[:pp].*) | ||
.where(Sequel[:pp][:provider_id] => provider_id) | ||
.join_successful_non_wip_verifications_for_provider_id(provider_id) | ||
.join_provider_version_tags do | ||
Sequel.lit('provider_tags.name != ?', provider_tag) | ||
end | ||
.verified_before_creation_date_of(first_tag_with_name) | ||
.distinct | ||
end | ||
|
||
protected | ||
|
||
def verified_before_date(date) | ||
where { Sequel[:verifications][:execution_date] < date } | ||
end | ||
|
||
def join_successful_non_wip_verifications_for_provider_id(provider_id, &block) | ||
verifications_join = { | ||
pact_version_id: :pact_version_id, | ||
Sequel[:verifications][:success] => true, | ||
Sequel[:verifications][:wip] => false, | ||
Sequel[:verifications][:provider_id] => provider_id | ||
} | ||
join(:verifications, verifications_join, {}, &block) | ||
end | ||
|
||
def join_provider_version_tags &block | ||
tags_join = { | ||
Sequel[:verifications][:provider_version_id] => Sequel[:provider_tags][:version_id], | ||
} | ||
join(:tags, tags_join, { table_alias: :provider_tags }, &block) | ||
end | ||
|
||
def join_provider_version_tags_for_tag(tag) | ||
tags_join = { | ||
Sequel[:verifications][:provider_version_id] => Sequel[:provider_tags][:version_id], | ||
Sequel[:provider_tags][:name] => tag | ||
} | ||
join(:tags, tags_join, { table_alias: :provider_tags } ) | ||
end | ||
|
||
def join_provider_versions_for_provider_id_and_branch(provider_id, provider_version_branch) | ||
versions_join = { | ||
Sequel[:verifications][:provider_version_id] => Sequel[:provider_versions][:id], | ||
Sequel[:provider_versions][:branch] => provider_version_branch, | ||
Sequel[:provider_versions][:pacticipant_id] => provider_id | ||
} | ||
join(:versions, versions_join, { table_alias: :provider_versions } ) | ||
end | ||
|
||
def join_provider_versions_for_provider_id(provider_id, &block) | ||
versions_join = { | ||
Sequel[:verifications][:provider_version_id] => Sequel[:provider_versions][:id], | ||
Sequel[:provider_versions][:pacticipant_id] => provider_id | ||
} | ||
join(:versions, versions_join, { table_alias: :provider_versions }, &block) | ||
end | ||
|
||
def verified_before_creation_date_of(record) | ||
if record | ||
verified_before_date(record.created_at) | ||
else | ||
self | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.