diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-23 03:08:53 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-23 03:08:53 +0000 |
commit | ccaa94488202341c25d24f6f16a70a9f658fc742 (patch) | |
tree | 886b8d0d4c14585243f3ccb439057e19f1860767 /app | |
parent | d65442b1d9621da6749d59ea1a544a2ea39b3a79 (diff) | |
download | gitlab-ce-ccaa94488202341c25d24f6f16a70a9f658fc742.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/models/error_tracking/project_error_tracking_setting.rb | 10 | ||||
-rw-r--r-- | app/services/error_tracking/issue_update_service.rb | 18 |
2 files changed, 21 insertions, 7 deletions
diff --git a/app/models/error_tracking/project_error_tracking_setting.rb b/app/models/error_tracking/project_error_tracking_setting.rb index 5b13d0b628a..d73c177db26 100644 --- a/app/models/error_tracking/project_error_tracking_setting.rb +++ b/app/models/error_tracking/project_error_tracking_setting.rb @@ -126,6 +126,10 @@ module ErrorTracking end end + def expire_issues_cache + Rails.cache.delete_matched(expand_cache_key('list_issues')) + end + # http://HOST/api/0/projects/ORG/PROJECT # -> # http://HOST/ORG/PROJECT @@ -142,6 +146,12 @@ module ErrorTracking private + def expand_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 diff --git a/app/services/error_tracking/issue_update_service.rb b/app/services/error_tracking/issue_update_service.rb index db754d54fef..8c9d52cefd9 100644 --- a/app/services/error_tracking/issue_update_service.rb +++ b/app/services/error_tracking/issue_update_service.rb @@ -2,6 +2,8 @@ module ErrorTracking class IssueUpdateService < ErrorTracking::BaseService + include ::Gitlab::Utils::StrongMemoize + private def perform @@ -9,6 +11,7 @@ module ErrorTracking unless parse_errors(response).present? response[:closed_issue_iid] = update_related_issue&.iid + project_error_tracking_setting.expire_issues_cache end response @@ -22,10 +25,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 close_and_create_note(issue) @@ -49,10 +51,12 @@ module ErrorTracking end def related_issue - SentryIssueFinder - .new(project, current_user: current_user) - .execute(params[:issue_id]) - &.issue + strong_memoize(:related_issue) do + SentryIssueFinder + .new(project, current_user: current_user) + .execute(params[:issue_id]) + &.issue + end end def resolving? |