Sha256: e682db375ab098b0da288f44e340ee31a6e33b96b2449b6406ff2105260244ee

Contents?: true

Size: 838 Bytes

Versions: 21

Compression:

Stored size: 838 Bytes

Contents

module ClassMethods
  def update_all_storage_locations
    Card.search(type_id: ["in", FileID, ImageID])
        .each(&:update_storage_location!)
  end

  def delete_tmp_files_of_cached_uploads
    draft_actions_with_attachment.each do |action|
      # we don't want to delete uploads in progress
      next unless old_enough?(action.created_at) && (card = action.card)
      card.delete_files_for_action action
      action.delete
    end
  end

  def old_enough? time, expiration_time=5.day.to_i
    Time.now - time > expiration_time
  end

  def draft_actions_with_attachment
    Card::Action.find_by_sql(
      "SELECT * FROM card_actions "\
        "INNER JOIN cards ON card_actions.card_id = cards.id "\
        "WHERE cards.type_id IN (#{Card::FileID}, #{Card::ImageID}) "\
        "AND card_actions.draft = true"
    )
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
card-1.93.4 mod/carrierwave/set/all/file_utils.rb
card-1.93.3 mod/carrierwave/set/all/file_utils.rb
card-1.93.2 mod/carrierwave/set/all/file_utils.rb
card-1.93.1 mod/carrierwave/set/all/file_utils.rb
card-1.93.0 mod/carrierwave/set/all/file_utils.rb
card-1.92.2 mod/carrierwave/set/all/file_utils.rb
card-1.92.1 mod/carrierwave/set/all/file_utils.rb
card-1.92 mod/carrierwave/set/all/file_utils.rb
card-1.91 mod/carrierwave/set/all/file_utils.rb
card-1.21.0 mod/carrierwave/set/all/file_utils.rb
card-1.20.4 mod/carrierwave/set/all/file_utils.rb
card-1.20.3 mod/carrierwave/set/all/file_utils.rb
card-1.20.2 mod/carrierwave/set/all/file_utils.rb
card-1.20.1 mod/carrierwave/set/all/file_utils.rb
card-1.20.0 mod/carrierwave/set/all/file_utils.rb
card-1.19.6 mod/carrierwave/set/all/file_utils.rb
card-1.19.5 mod/carrierwave/set/all/file_utils.rb
card-1.19.4 mod/carrierwave/set/all/file_utils.rb
card-1.19.3 mod/carrierwave/set/all/file_utils.rb
card-1.19.2 mod/carrierwave/set/all/file_utils.rb