Skip to content

Commit

Permalink
Add Rake task to update draft status of assets for attachments
Browse files Browse the repository at this point in the history
  • Loading branch information
floehopper committed Feb 15, 2018
1 parent ac55788 commit 80cf141
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lib/tasks/asset_manager.rake
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,20 @@ namespace :asset_manager do
end
end

namespace :attachments do
desc 'Update draft status for Asset Manager assets associated with attachments'
task :update_draft_status, %i(first_id last_id) => :environment do |_, args|
first_id = args[:first_id]
last_id = args[:last_id]
abort(update_draft_status_usage_string) unless first_id && last_id
options = { start: first_id, finish: last_id }
updater = ServiceListeners::AttachmentDraftStatusUpdater
Attachment.includes(:attachment_data).find_each(options) do |attachment|
updater.new(attachment, queue: 'asset_migration').update!
end
end
end

private

def usage_string
Expand All @@ -42,4 +56,11 @@ namespace :asset_manager do
Where <batch_start> and <batch_end> are integers corresponding to the directory names under `system/uploads/attachment_data/file`. e.g. `system/uploads/attachment_data/file/100` will be migrated if <batch_start> <= 100 and <batch_end> >= 100.
}
end

def update_draft_status_usage_string
%{Usage: asset_manager:attachments:update_draft_status[<first_id>,<last_id>]
Where <first_id> and <last_id> are Attachment database IDs.
}
end
end

0 comments on commit 80cf141

Please sign in to comment.