2013-08-01 01:46:24 +00:00
|
|
|
module JamRuby
|
|
|
|
|
class CrashDump < ActiveRecord::Base
|
|
|
|
|
|
2015-12-09 17:32:24 +00:00
|
|
|
include JamRuby::S3ManagerMixin
|
|
|
|
|
|
2013-08-01 01:46:24 +00:00
|
|
|
self.table_name = "crash_dumps"
|
|
|
|
|
|
|
|
|
|
self.primary_key = 'id'
|
2013-08-09 02:12:43 +00:00
|
|
|
|
|
|
|
|
belongs_to :user, :inverse_of => :crash_dumps, :class_name => "JamRuby::User"
|
2013-08-01 01:46:24 +00:00
|
|
|
|
|
|
|
|
validates :client_type, presence: true
|
2013-08-06 15:15:39 +00:00
|
|
|
validates :client_version, presence: true
|
2013-08-01 02:05:38 +00:00
|
|
|
|
2013-08-09 02:12:43 +00:00
|
|
|
attr_accessor :user_email
|
|
|
|
|
|
2013-08-01 02:05:38 +00:00
|
|
|
before_validation(:on => :create) do
|
|
|
|
|
self.created_at ||= Time.now
|
|
|
|
|
self.id = SecureRandom.uuid
|
2016-01-04 17:28:10 +00:00
|
|
|
self.uri = "dumps/#{created_at.strftime('%Y-%m-%d')}/#{self.id}.zip"
|
2013-08-01 02:05:38 +00:00
|
|
|
end
|
2013-08-09 02:12:43 +00:00
|
|
|
|
|
|
|
|
def user_email
|
|
|
|
|
nil if user_id.nil?
|
|
|
|
|
self.user.email
|
|
|
|
|
end
|
|
|
|
|
|
2015-12-09 17:32:24 +00:00
|
|
|
def sign_url(expiration_time = 3600 * 24 * 7, secure=true)
|
|
|
|
|
s3_manager.sign_url(self[:ri], {:expires => expiration_time, :secure => secure})
|
|
|
|
|
end
|
2013-08-01 01:46:24 +00:00
|
|
|
end
|
|
|
|
|
end
|