FEATURE: rename task to posts:destroy_old_data_exports

Previously we were only catching one type of data export, the new job will
catch every csv export we have

Job is pretty safe as it filters on system user id / pm with a particular
slug
This commit is contained in:
Sam Saffron 2019-05-23 15:02:18 +10:00
parent 553ffbfcb5
commit 96e58125a7
1 changed files with 6 additions and 6 deletions

View File

@ -494,16 +494,16 @@ task 'posts:missing_uploads', [:single_site] => :environment do |_, args|
end
end
def destroy_old_user_data_exports
def destroy_old_data_exports
topics = Topic.with_deleted.where(<<~SQL, 2.days.ago)
slug = 'user-archive-data-export-complete' AND
slug = '%-export-complete' AND
archetype = 'private_message' AND
posts_count = 1 AND
created_at < ? AND
user_id = -1
SQL
puts "Found #{topics.count} old user data exports on #{RailsMultisite::ConnectionManagement.current_db}, destroying"
puts "Found #{topics.count} old CSV data exports on #{RailsMultisite::ConnectionManagement.current_db}, destroying"
puts
topics.each do |t|
Topic.transaction do
@ -516,12 +516,12 @@ def destroy_old_user_data_exports
end
desc 'destroys all user archive PMs (they may contain broken images)'
task 'posts:destroy_old_user_data_exports' => :environment do
task 'posts:destroy_old_data_exports' => :environment do
if RailsMultisite::ConnectionManagement.current_db != "default"
destroy_old_user_data_exports
destroy_old_data_exports
else
RailsMultisite::ConnectionManagement.each_connection do
destroy_old_user_data_exports
destroy_old_data_exports
end
end
end