Skip to content

Commit

Permalink
feat(clean): update default selectors for clean task to include deplo…
Browse files Browse the repository at this point in the history
…yed, released and branch head versions
  • Loading branch information
bethesque committed Aug 17, 2021
1 parent 98cad4a commit aaffe71
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions lib/pact_broker/db/clean_incremental.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
require "pact_broker/logging"
require "pact_broker/matrix/unresolved_selector"
require "pact_broker/date_helper"

require "pact_broker/db/clean/selector"

module PactBroker
module DB
class CleanIncremental
DEFAULT_KEEP_SELECTORS = [
PactBroker::Matrix::UnresolvedSelector.new(tag: true, latest: true),
PactBroker::Matrix::UnresolvedSelector.new(latest: true),
PactBroker::Matrix::UnresolvedSelector.new(max_age: 90)
PactBroker::DB::Clean::Selector.new(tag: true, latest: true),
PactBroker::DB::Clean::Selector.new(branch: true, latest: true),
PactBroker::DB::Clean::Selector.new(latest: true),
PactBroker::DB::Clean::Selector.new(deployed: true),
PactBroker::DB::Clean::Selector.new(released: true),
PactBroker::DB::Clean::Selector.new(max_age: 90)
]
TABLES = [:versions, :pact_publications, :pact_versions, :verifications, :triggered_webhooks, :webhook_executions]

Expand All @@ -27,7 +30,12 @@ def logger
end

def keep
options[:keep] || DEFAULT_KEEP_SELECTORS
@keep ||= if options[:keep]
# Could be a Matrix::UnresolvedSelector from the docker image, convert it
options[:keep].collect { | unknown_thing | PactBroker::DB::Clean::Selector.from_hash(unknown_thing.to_hash) }
else
DEFAULT_KEEP_SELECTORS
end
end

def limit
Expand Down

0 comments on commit aaffe71

Please sign in to comment.