Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor <idrozdov@gitlab.com>2019-08-10 00:01:55 +0300
committerDouwe Maan <douwe@gitlab.com>2019-08-10 00:01:55 +0300
commitb99011af62935de0b15e8a314ffb7df1f8a3f303 (patch)
treef19bc1052fa1cd903a31d6f01489b56ec2bb7ead /app/models
parent43b9be9d6cf59a02ea86795a1734848615d38a26 (diff)
Split MR widget into cached and non-cached serializers
Splits auto-refreshing of MR widget into 2 requests: - the one which uses etag-caching and invalidates the fields on change - the one without caching The idea is to gradually move all the fields to etag-cached endpoint
Diffstat (limited to 'app/models')
-rw-r--r--app/models/issue.rb2
-rw-r--r--app/models/merge_request.rb16
2 files changed, 17 insertions, 1 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb
index bc5ec94081b..c5a18f0af0f 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -64,7 +64,7 @@ class Issue < ApplicationRecord
scope :public_only, -> { where(confidential: false) }
scope :confidential_only, -> { where(confidential: true) }
- after_save :expire_etag_cache
+ after_commit :expire_etag_cache
after_save :ensure_metrics, unless: :imported?
attr_spammable :title, spam_title: true
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb
index 4c4883fc022..4306dd9266f 100644
--- a/app/models/merge_request.rb
+++ b/app/models/merge_request.rb
@@ -73,6 +73,7 @@ class MergeRequest < ApplicationRecord
after_update :clear_memoized_shas
after_update :reload_diff_if_branch_changed
after_save :ensure_metrics
+ after_commit :expire_etag_cache
# When this attribute is true some MR validation is ignored
# It allows us to close or modify broken merge requests
@@ -389,6 +390,10 @@ class MergeRequest < ApplicationRecord
def merge_async(user_id, params)
jid = MergeWorker.perform_async(id, user_id, params.to_h)
update_column(:merge_jid, jid)
+
+ # merge_ongoing? depends on merge_jid
+ # expire etag cache since the attribute is changed without triggering callbacks
+ expire_etag_cache
end
# Set off a rebase asynchronously, atomically updating the `rebase_jid` of
@@ -409,6 +414,10 @@ class MergeRequest < ApplicationRecord
update_column(:rebase_jid, jid)
end
+
+ # rebase_in_progress? depends on rebase_jid
+ # expire etag cache since the attribute is changed without triggering callbacks
+ expire_etag_cache
end
def merge_participants
@@ -1429,4 +1438,11 @@ class MergeRequest < ApplicationRecord
variables.append(key: 'CI_MERGE_REQUEST_SOURCE_BRANCH_NAME', value: source_branch.to_s)
end
end
+
+ def expire_etag_cache
+ return unless project.namespace
+
+ key = Gitlab::Routing.url_helpers.cached_widget_project_json_merge_request_path(project, self, format: :json)
+ Gitlab::EtagCaching::Store.new.touch(key)
+ end
end