Skip to content

Commit

Permalink
Merge pull request #8286 from alphagov/attachmentdata_migration_preve…
Browse files Browse the repository at this point in the history
…nt_csv

Prevent AttachmentData migration task from running against csv files …
  • Loading branch information
JessyTW authored Sep 21, 2023
2 parents d353912 + 114e06a commit 31de98b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/workers/create_asset_relationship_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class CreateAssetRelationshipWorker < WorkerBase
def perform(start_id, end_id)
logger.info("CreateAssetRelationshipWorker start!")
assetable_type = AttachmentData
assetables = assetable_type.where(id: start_id..end_id)
assetables = assetable_type.where(id: start_id..end_id).where.not(content_type: "text/csv")
logger.info "Number of #{assetable_type} found: #{assetables.count}"
logger.info "Creating Asset for records from #{start_id} to #{end_id}"

Expand All @@ -11,6 +11,7 @@ def perform(start_id, end_id)
assetables.each do |assetable|
assetable.use_non_legacy_endpoints = true
assetable.save!

begin
path = save_asset_original(assetable, assetable_type.to_s)
asset_counter += 1
Expand All @@ -29,6 +30,7 @@ def perform(start_id, end_id)

count += 1
end

logger.info("Created assets for #{count} assetable")
logger.info("Created asset counter #{asset_counter}")
logger.info("CreateAssetRelationshipWorker finish!")
Expand Down

0 comments on commit 31de98b

Please sign in to comment.