scope :visible_to, ->(u) { visible.where(:visibility => %w[public identifiable]).or(visible.where(:user => u)) }
scope :visible_to_all, -> { where(:visibility => %w[public identifiable]) }
scope :tagged, ->(t) { joins(:tags).where(:gpx_file_tags => { :tag => t }) }
+ scope :imported, -> { where(:inserted => true) }
has_one_attached :file, :service => Settings.trace_file_storage
has_one_attached :image, :service => Settings.trace_image_storage
:content_type => content_type(attachable.path),
:identify => false)
else
- super(attachable)
+ super
end
end
end
end
+ def schedule_import
+ TraceImporterJob.new(self).enqueue(:priority => user.traces.where(:inserted => false).count)
+ end
+
+ def schedule_destruction
+ TraceDestroyerJob.perform_later(self)
+ end
+
private
def content_type(file)