5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-15 22:51:41 +00:00

Merge branch 'issue-10031' into 'rails'

deploys #10031

Closes #12747, #10109, #10108, #10107, #10106, #10105, #10104, #10103, #10102, #10101, #10100, #10099, #10098, #10097, #10096, #10095, #10094, #10093, #10092, #10091, #10090, #10089, #10088, #10087, #10086, #10085, #10084, #10083, #10082, #10081, #10080, #10079, #10078, #10077, #10076, #10075, #10074, #10073, #10072, #10071, #10070, #10069, #10068, #10067, #10066, #10065, #10064, #10063, #10062, #10061, #10060, #10059, #10058, #10057, #10056, #10055, #10054, #10053, #10052, #10330, #10329, #10328, #10327, #10326, #10325, #10324, #10323, #10322, #10321, #10320, #10319, #10318, #10317, #10316, #10315, #10314, #10313, #10312, #10311, #10310, #10309, #10308, #10307, #10306, #10305, #10304, #10303, #10302, #10301, #10300, #10299, #10298, #10297, #10296, #10295, #10294, #10293, #10292, #10291, #10290, #10289, #10288, #10287, #10286, #10285, #10284, #10283, #10282, #10281, #10280, #10279, #10278, #10277, #10276, #10275, #10274, #10273, #10272, #10271, #10270, #10269, #10268, #10267, #10266, #10265, #10264, #10263, #10262, #10261, #10260, #10259, #10258, #10257, #10256, #10255, #10254, #10253, #10252, #10251, #10250, #10249, #10248, #10247, #10246, #10244, #10243, #10242, #10241, #10240, #10239, #10238, #10237, #10236, #10235, #10234, #10232, #10231, #10230, #10229, #10228, #10227, #10226, #10225, #10224, #10223, #10222, #10221, #10220, #10219, #10218, #10217, #10216, #10215, #10214, #10213, #10212, #10211, #10210, #10209, #10208, #10207, #10206, #10205, #10204, #10203, #10202, #10201, #10200, #10199, #10198, #10197, #10196, #10195, #10194, #10193, #10192, #10191, #10190, #10189, #10188, #10187, #10186, #10185, #10184, #10183, #10182, #10181, #10180, #10179, #10178, #10177, #10176, #10175, #10174, #10173, #10172, #10171, #10170, #10169, #10168, #10167, #10166, #10165, #10164, #10163, #10162, #10161, #10160, #10159, #10158, #10157, #10156, #10155, #10154, #10153, #10152, #10151, #10150, #10149, #10148, #10147, #10146, #10145, #10144, #10143, #10142, #10141, #10140, #10139, #10138, #10137, #10136, #10135, #10134, #10133, #10132, #10131, #10130, #10129, #10128, #10127, #10126, #10125, #3693, #3681, #3465, #3414, #3330, #3002, #2941, #2632, #2587, #2531, #2511, #2499, #2460, #2062, #2059, #2058, #2057, #1952, #1832, #1746, #1744, #1743, #1741, #1740, #1739, #1738, #1735, #1730, #1716, #1667, #1610, #1609, #1478, #1461, #1303, #1230, #1191, #1175, #1154, #1153, #1152, #1124, #1104, #10413, #10412, #10411, #10410, #10409, #10408, #10407, #10406, #10405, #10404, #10403, #10402, #10401, #10400, #10399, #10398, #10397, #10396, #10395, #10394, #10393, #10392, #10391, #10390, #10389, #10388, #10387, #10386, #10385, #10384, #10383, #10382, #10381, #10380, #10379, #10378, #10377, #10376, #10375, #10374, #10373, #10372, #10371, #10370, #10369, #10368, #10367, #10366, #10365, #10364, #10362, #10361, #10360, #10359, #10358, #10357, #10356, #10355, #10354, #10353, #10352, #10351, #10350, #10349, #10348, #10347, #10346, #10345, #10343, #10342, #10341, #10340, #10339, #10338, #10337, #10336, #10335, #10334, #10333, #10332, #10331, #10124, #10123, #10122, #10121, #10120, #10119, #10118, #10117, #10116, #10115, #10114, #10113, #10112, #10111, #10110, #9996, #9990, #9955, #9939, #9901, #9896, #9893, #9857, #9810, #9385, #9370, #9360, #9024, #8846, #8799, #8751, #8678, #8529, #8168, #7861, #7685, #7645, #7630, #7575, #7549, #7386, #6177, #6066, #5832, #5147, #504, #5022, #4949, #4947, #4899, #4896, #4874, #4860, #4804, #4798, #4740, #4679, #4677, #4668, #4641, #4574, #4537, #4536, #4416, #4407, #4312, #4215, #4201, #4175, #4042, #3915, #3858, #3833, #3819, #3811, #3764, and #3719

See merge request sutty/sutty!119
This commit is contained in:
fauno 2023-04-10 15:50:24 +00:00
commit 92bba68fd5
2 changed files with 35 additions and 15 deletions

View file

@ -16,7 +16,7 @@ class GitlabNotifierJob < ApplicationJob
# @param [Hash] opciones de ExceptionNotifier
def perform(exception, **options)
@exception = exception
@options = options
@options = fix_options options
@issue_data = { count: 1 }
# Necesitamos saber si el issue ya existía
@cached = false
@ -37,7 +37,7 @@ class GitlabNotifierJob < ApplicationJob
}
end
unless @issue['iid']
if @issue['iid'].blank? && issue_data[:issue].blank?
Rails.cache.delete(cache_key)
raise GitlabNotifierError, @issue.dig('message', 'title')&.join(', ')
end
@ -61,9 +61,9 @@ class GitlabNotifierJob < ApplicationJob
Rails.cache.write(cache_key, issue_data)
# Si este trabajo genera una excepción va a entrar en un loop, así que
# la notificamos por correo
rescue Exception => e
email_notification.call(e)
email_notification.call(exception, options)
rescue StandardError => e
email_notification.call(e, data: @issue)
email_notification.call(exception, data: @options)
end
private
@ -84,10 +84,15 @@ class GitlabNotifierJob < ApplicationJob
exception.class.name,
Digest::SHA1.hexdigest(exception.message),
Digest::SHA1.hexdigest(backtrace&.first.to_s),
Digest::SHA1.hexdigest(options.dig(:data, :params, 'errors').to_s)
Digest::SHA1.hexdigest(errors.to_s)
].join('/')
end
# @return [Array]
def errors
options.dig(:data, :params, 'errors') || []
end
# Define si es una excepción de javascript o local
#
# @see BacktraceJob
@ -126,6 +131,7 @@ class GitlabNotifierJob < ApplicationJob
# @return [String]
def body
@body ||= ''.dup.tap do |b|
b << log_section
b << request_section
b << javascript_footer
b << data_section
@ -162,14 +168,16 @@ class GitlabNotifierJob < ApplicationJob
# @return [String]
def log_section
return '' unless options[:log]
return '' unless options.dig(:data, :log)
<<~LOG
# Log
# Build log
```
#{options[:log]}
#{options[:data].delete(:log)}
```
LOG
end
@ -257,8 +265,8 @@ class GitlabNotifierJob < ApplicationJob
## Data
```
#{pp options[:data]}
```yaml
#{options[:data].to_yaml}
```
DATA
@ -279,4 +287,16 @@ class GitlabNotifierJob < ApplicationJob
def url
@url ||= request&.url || options.dig(:data, :params, 'context', 'url')
end
# Define llaves necesarias
#
# @param :options [Hash]
# @return [Hash]
def fix_options(options)
options = { data: options } unless options.is_a? Hash
options[:data] ||= {}
options[:data][:params] ||= {}
options
end
end

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true
# Enviar una notificación cuando falla una tarea
SuckerPunch.exception_handler = lambda { |ex, _klass, _args|
ExceptionNotifier.notify_exception(ex)
SuckerPunch.exception_handler = lambda { |ex, _, args|
ExceptionNotifier.notify_exception(ex, data: args.last)
}