discourse/app/models/user_export.rb

38 lines
1000 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2014-12-28 11:13:49 -05:00
class UserExport < ActiveRecord::Base
belongs_to :user
belongs_to :upload, dependent: :destroy
around_destroy :ignore_missing_post_uploads
def ignore_missing_post_uploads
post_ids = upload.post_uploads.pluck(:post_id)
yield
post_ids.each { |post_id| PostCustomField.create!(post_id: post_id, name: Post::MISSING_UPLOADS_IGNORED, value: "t") }
end
def self.remove_old_exports
UserExport.where('created_at < ?', 2.days.ago).find_each do |user_export|
user_export.destroy!
end
end
def self.base_directory
File.join(Rails.root, "public", "uploads", "csv_exports", RailsMultisite::ConnectionManagement.current_db)
end
end
# == Schema Information
#
2014-12-28 11:13:49 -05:00
# Table name: user_exports
#
2015-02-04 00:34:25 -05:00
# id :integer not null, primary key
2019-01-11 14:29:56 -05:00
# file_name :string not null
2015-02-04 00:34:25 -05:00
# user_id :integer not null
2019-01-11 14:29:56 -05:00
# created_at :datetime not null
# updated_at :datetime not null
# upload_id :integer
#