Sha256: 870b61abbf8ec6d873ee8b0afecccc1901549cf207e6b26407cc8fd5003ae433

Contents?: true

Size: 1.01 KB

Versions: 38

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

namespace :decidim_votings_census do
  # Removes the census access code export files older than the configured expiry time.
  desc "Deletes the census access codes export file `Decidim::Votings::Census.census_access_codes_export_expiry_time` from now."
  task delete_census_access_codes_export: :environment do
    puts "DELETE CENSUS ACCESS CODES EXPORT: -------------- START"
    attachments = ActiveStorage::Attachment.joins(:blob).where(
      name: "access_codes_file",
      record_type: "Decidim::Votings::Census::Dataset"
    ).where(
      "active_storage_blobs.created_at < ?", Decidim::Votings::Census.census_access_codes_export_expiry_time.ago
    )
    attachments.each do |attachment|
      delete_census_access_codes_export_file attachment
    end
    puts "DELETE CENSUS ACCESS CODES EXPORT: --------------- END"
  end

  def delete_census_access_codes_export_file(attachment)
    puts "------"
    puts "!! deleting: #{attachment.filename}"
    attachment.purge
    puts "ok----"
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
decidim-elections-0.28.4 lib/tasks/decidim_voting_census.rake
decidim-elections-0.27.9 lib/tasks/decidim_voting_census.rake
decidim-elections-0.28.3 lib/tasks/decidim_voting_census.rake
decidim-elections-0.27.8 lib/tasks/decidim_voting_census.rake
decidim-elections-0.28.2 lib/tasks/decidim_voting_census.rake
decidim-elections-0.27.7 lib/tasks/decidim_voting_census.rake
decidim-elections-0.28.1 lib/tasks/decidim_voting_census.rake
decidim-elections-0.27.6 lib/tasks/decidim_voting_census.rake
decidim-elections-0.26.10 lib/tasks/decidim_voting_census.rake
decidim-elections-0.26.9 lib/tasks/decidim_voting_census.rake
decidim-elections-0.28.0 lib/tasks/decidim_voting_census.rake
decidim-elections-0.27.5 lib/tasks/decidim_voting_census.rake
decidim-elections-0.28.0.rc5 lib/tasks/decidim_voting_census.rake
decidim-elections-0.28.0.rc4 lib/tasks/decidim_voting_census.rake
decidim-elections-0.26.8 lib/tasks/decidim_voting_census.rake
decidim-elections-0.27.4 lib/tasks/decidim_voting_census.rake
decidim-elections-0.27.3 lib/tasks/decidim_voting_census.rake
decidim-elections-0.26.7 lib/tasks/decidim_voting_census.rake
decidim-elections-0.26.5 lib/tasks/decidim_voting_census.rake
decidim-elections-0.27.2 lib/tasks/decidim_voting_census.rake