mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-14 17:51:41 +00:00
fix: informar cuando no se puede procesar un issue
This commit is contained in:
parent
e0a7232643
commit
8c5a109610
1 changed files with 10 additions and 2 deletions
|
@ -3,6 +3,8 @@
|
|||
# Notifica excepciones a una instancia de Gitlab, como incidencias
|
||||
# nuevas o como comentarios a las incidencias pre-existentes.
|
||||
class GitlabNotifierJob < ApplicationJob
|
||||
class GitlabNotifierError < StandardError; end
|
||||
|
||||
include ExceptionNotifier::BacktraceCleaner
|
||||
|
||||
# Variables que vamos a acceder luego
|
||||
|
@ -18,22 +20,28 @@ class GitlabNotifierJob < ApplicationJob
|
|||
@issue_data = { count: 1 }
|
||||
# Necesitamos saber si el issue ya existía
|
||||
@cached = false
|
||||
@issue = {}
|
||||
|
||||
# Traemos los datos desde la caché si existen, sino generamos un
|
||||
# issue nuevo e inicializamos la caché
|
||||
@issue_data = Rails.cache.fetch(cache_key) do
|
||||
issue = client.new_issue confidential: true, title: title, description: description, issue_type: 'incident'
|
||||
@issue = client.new_issue confidential: true, title: title, description: description, issue_type: 'incident'
|
||||
@cached = true
|
||||
|
||||
{
|
||||
count: 1,
|
||||
issue: issue['iid'],
|
||||
issue: @issue['iid'],
|
||||
user_agents: [user_agent].compact,
|
||||
params: [request&.filtered_parameters].compact,
|
||||
urls: [url].compact
|
||||
}
|
||||
end
|
||||
|
||||
unless @issue['iid']
|
||||
Rails.cache.delete(cache_key)
|
||||
raise GitlabNotifierError, @issue.dig('message', 'title')&.join(', ')
|
||||
end
|
||||
|
||||
# No seguimos actualizando si acabamos de generar el issue
|
||||
return if cached
|
||||
|
||||
|
|
Loading…
Reference in a new issue