Commit 3fc60058 authored by Sean Arnold's avatar Sean Arnold Committed by Douglas Barbosa Alexandre

Tidy up code and remove duplicate method

- Move cache key to new method
- Memoize related_issue
parent 156baa54
......@@ -140,15 +140,20 @@ module ErrorTracking
Addressable::URI.join(api_url, '/').to_s
end
def clear_cache(key_prefix)
return unless key_prefix
def clear_cache(resource_prefix)
raise 'No resource prefix provided' unless resource_prefix
klass_key = self.class.reactive_cache_key.call(self).join(':')
Rails.cache.delete_matched("#{klass_key}:#{key_prefix}*")
Rails.cache.delete_matched(cache_key(resource_prefix))
end
private
def cache_key(resource_prefix)
klass_key = self.class.reactive_cache_key.call(self).join(':')
"#{klass_key}:#{resource_prefix}*"
end
def add_gitlab_issue_details(issue)
issue.gitlab_commit = match_gitlab_commit(issue.first_release_version)
issue.gitlab_commit_path = project_commit_path(project, issue.gitlab_commit) if issue.gitlab_commit
......
......@@ -23,10 +23,9 @@ module ErrorTracking
end
def update_related_issue
issue = related_issue
return unless issue
return if related_issue.nil?
close_and_create_note(issue)
close_and_create_note(related_issue)
end
def clear_cache
......@@ -54,11 +53,13 @@ module ErrorTracking
end
def related_issue
strong_memoize(:related_issue) do
SentryIssueFinder
.new(project, current_user: current_user)
.execute(params[:issue_id])
&.issue
end
end
def resolving?
update_params[:status] == 'resolved'
......
......@@ -105,12 +105,6 @@ module SystemNoteService
create_note(NoteSummary.new(issue, project, author, body, action: 'closed'))
end
def close_after_error_tracking_resolve(issue, project, author)
body = _('resolved the corresponding error and closed the issue.')
create_note(NoteSummary.new(issue, project, author, body, action: 'closed'))
end
def change_status(noteable, project, author, status, source = nil)
::SystemNotes::IssuablesService.new(noteable: noteable, project: project, author: author).change_status(status, source)
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment