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 ...@@ -140,15 +140,20 @@ module ErrorTracking
Addressable::URI.join(api_url, '/').to_s Addressable::URI.join(api_url, '/').to_s
end end
def clear_cache(key_prefix) def clear_cache(resource_prefix)
return unless key_prefix raise 'No resource prefix provided' unless resource_prefix
klass_key = self.class.reactive_cache_key.call(self).join(':') Rails.cache.delete_matched(cache_key(resource_prefix))
Rails.cache.delete_matched("#{klass_key}:#{key_prefix}*")
end end
private 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) def add_gitlab_issue_details(issue)
issue.gitlab_commit = match_gitlab_commit(issue.first_release_version) 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 issue.gitlab_commit_path = project_commit_path(project, issue.gitlab_commit) if issue.gitlab_commit
......
...@@ -23,10 +23,9 @@ module ErrorTracking ...@@ -23,10 +23,9 @@ module ErrorTracking
end end
def update_related_issue def update_related_issue
issue = related_issue return if related_issue.nil?
return unless issue
close_and_create_note(issue) close_and_create_note(related_issue)
end end
def clear_cache def clear_cache
...@@ -54,10 +53,12 @@ module ErrorTracking ...@@ -54,10 +53,12 @@ module ErrorTracking
end end
def related_issue def related_issue
SentryIssueFinder strong_memoize(:related_issue) do
.new(project, current_user: current_user) SentryIssueFinder
.execute(params[:issue_id]) .new(project, current_user: current_user)
&.issue .execute(params[:issue_id])
&.issue
end
end end
def resolving? def resolving?
......
...@@ -105,12 +105,6 @@ module SystemNoteService ...@@ -105,12 +105,6 @@ module SystemNoteService
create_note(NoteSummary.new(issue, project, author, body, action: 'closed')) create_note(NoteSummary.new(issue, project, author, body, action: 'closed'))
end 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) def change_status(noteable, project, author, status, source = nil)
::SystemNotes::IssuablesService.new(noteable: noteable, project: project, author: author).change_status(status, source) ::SystemNotes::IssuablesService.new(noteable: noteable, project: project, author: author).change_status(status, source)
end 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