diff --git a/hyrax/lib/tasks/delete_crc_1280_works_and_collections.rake b/hyrax/lib/tasks/delete_crc_1280_works_and_collections.rake new file mode 100644 index 0000000000000000000000000000000000000000..db3ef3f628aaffcce71d2cbb408d6690cb9f0c1d --- /dev/null +++ b/hyrax/lib/tasks/delete_crc_1280_works_and_collections.rake @@ -0,0 +1,34 @@ +# frozen_string_literal: true +namespace :rdms do + desc 'Delete CRC1280 works and collections. usage: rdms:delete_crc_1280_works_and_collections["dry_run"]' + task :"delete_crc_1280_works_and_collections", [:dry_run] => :environment do |task, args| + crc_1280_datasets_to_delete = [] + CrcDataset.all.each do |c| + if args.dry_run.present? + crc_1280_datasets_to_delete << c.id + else + puts "Deleting Crc 1280 dataset #{c.id}" + c.delete + end + end + if args.dry_run.present? + puts "IDs of all Crc 1280 Datasets to be deleted" + puts crc_1280_datasets_to_delete + end + crc_1280_collections_to_delete = [] + Collection.all.each do |c| + if c.collection_type.title == "CRC 1280" and c.title.first != "CRC 1280" + if args.dry_run.present? + crc_1280_collections_to_delete << c.id + else + puts "Deleting Crc 1280 collection #{c.id}" + c.delete + end + end + end + if args.dry_run.present? + puts "IDs of all Crc 1280 collections to be deleted" + puts crc_1280_collections_to_delete + end + end +end \ No newline at end of file