5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-22 04:26:22 +00:00

solo descargar archivos del sitio, faltaba la migración

This commit is contained in:
f 2020-12-07 13:36:09 -03:00
parent 0ce42f17b5
commit e53a560af0
2 changed files with 26 additions and 3 deletions

View file

@ -4,11 +4,14 @@
class BacktraceJob < ApplicationJob class BacktraceJob < ApplicationJob
queue_as :low_priority queue_as :low_priority
attr_reader :errors attr_reader :errors, :site_id
def perform(site_id:, errors:) def perform(site_id:, errors:)
@site_id = site_id
@errors = errors @errors = errors
return if files.empty?
errors.each do |error| errors.each do |error|
error['backtrace'].each do |backtrace| error['backtrace'].each do |backtrace|
offset = SourceMap::Offset.new(backtrace['line'], backtrace['column']) offset = SourceMap::Offset.new(backtrace['line'], backtrace['column'])
@ -25,15 +28,19 @@ class BacktraceJob < ApplicationJob
begin begin
raise NoMethodError raise NoMethodError
rescue NoMethodError => e rescue NoMethodError => e
ExceptionNotifier.notify_exception(e, data: { errors: errors }) ExceptionNotifier.notify_exception(e, data: { site: site.name, errors: errors })
end end
end end
private private
def site
@site ||= Site.find(site_id)
end
# Obtiene todos los archivos del backtrace # Obtiene todos los archivos del backtrace
def files 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 end
# Asume que todos los sourcemaps comparten la misma URL, lo # Asume que todos los sourcemaps comparten la misma URL, lo

View 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