Skip to content

Commit

Permalink
Merge pull request #2646 from alphagov/add-rake-task-to-remove-specia…
Browse files Browse the repository at this point in the history
…list-finder-docs-by-type

Add rake task to remove draft specialist finder docs
  • Loading branch information
lauraghiorghisor-tw authored Feb 21, 2024
2 parents c5ca22a + dae469f commit bbedecd
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/tasks/remove_draft_specialist_finder_docs.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
desc "Remove draft specialist finder docs by type"
task :remove_draft_specialist_finder_docs, [:document_type] => :environment do |_, args|
# document_type example: "farming_grant_option"
raise "Missing parameter: document_type" unless args.document_type

results = Queries::GetContentCollection.new(fields: %w[content_id], document_types: args.document_type).call
results.map do |payload|
Commands::V2::DiscardDraft.call(payload.deep_symbolize_keys)
rescue StandardError => e
Sidekiq.logger.info(e)
end
end

0 comments on commit bbedecd

Please sign in to comment.