Skip to content

Commit

Permalink
feat: call the database clean within a transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Dec 2, 2021
1 parent 34c989c commit 408c84e
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lib/pact_broker/db/clean_incremental.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,15 @@ def call
if dry_run?
dry_run_results
else
before_counts = current_counts
PactBroker::Domain::Version.where(id: resolve_ids(version_ids_to_delete)).delete
delete_orphan_pact_versions
after_counts = current_counts

TABLES.each_with_object({}) do | table_name, comparison_counts |
comparison_counts[table_name.to_s] = { "deleted" => before_counts[table_name] - after_counts[table_name], "kept" => after_counts[table_name] }
db.transaction do
before_counts = current_counts
PactBroker::Domain::Version.where(id: resolve_ids(version_ids_to_delete)).delete
delete_orphan_pact_versions
after_counts = current_counts

TABLES.each_with_object({}) do | table_name, comparison_counts |
comparison_counts[table_name.to_s] = { "deleted" => before_counts[table_name] - after_counts[table_name], "kept" => after_counts[table_name] }
end
end
end
end
Expand Down

0 comments on commit 408c84e

Please sign in to comment.