mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-25 05:06:22 +00:00
solo descargar archivos del sitio, faltaba la migración
This commit is contained in:
parent
0ce42f17b5
commit
e53a560af0
2 changed files with 26 additions and 3 deletions
|
@ -4,11 +4,14 @@
|
|||
class BacktraceJob < ApplicationJob
|
||||
queue_as :low_priority
|
||||
|
||||
attr_reader :errors
|
||||
attr_reader :errors, :site_id
|
||||
|
||||
def perform(site_id:, errors:)
|
||||
@site_id = site_id
|
||||
@errors = errors
|
||||
|
||||
return if files.empty?
|
||||
|
||||
errors.each do |error|
|
||||
error['backtrace'].each do |backtrace|
|
||||
offset = SourceMap::Offset.new(backtrace['line'], backtrace['column'])
|
||||
|
@ -25,15 +28,19 @@ class BacktraceJob < ApplicationJob
|
|||
begin
|
||||
raise NoMethodError
|
||||
rescue NoMethodError => e
|
||||
ExceptionNotifier.notify_exception(e, data: { errors: errors })
|
||||
ExceptionNotifier.notify_exception(e, data: { site: site.name, errors: errors })
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def site
|
||||
@site ||= Site.find(site_id)
|
||||
end
|
||||
|
||||
# Obtiene todos los archivos del backtrace
|
||||
def files
|
||||
@files ||= errors.map { |x| x['backtrace'] }.flatten.map { |x| x['file'].split('@').last }.uniq
|
||||
@files ||= errors.map { |x| x['backtrace'] }.flatten.map { |x| x['file'].split('@').last }.uniq.select { |x| x.start_with? site.url }
|
||||
end
|
||||
|
||||
# Asume que todos los sourcemaps comparten la misma URL, lo
|
||||
|
|
16
db/migrate/20201207152354_add_api_key_to_sites.rb
Normal file
16
db/migrate/20201207152354_add_api_key_to_sites.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
class AddApiKeyToSites < ActiveRecord::Migration[6.0]
|
||||
def up
|
||||
add_column :sites, :api_key_ciphertext, :string
|
||||
|
||||
begin
|
||||
Site.find_each do |site|
|
||||
site.update_attribute :api_key, SecureRandom.hex(64)
|
||||
end
|
||||
rescue Errno::ENOENT
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
remove_column :sites, :api_key_ciphertext
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue