diff options
author | Jan Provaznik <jprovaznik@gitlab.com> | 2018-08-16 15:01:27 +0200 |
---|---|---|
committer | Jan Provaznik <jprovaznik@gitlab.com> | 2018-08-17 19:14:48 +0200 |
commit | f3a3bc887ba44dbaac67238b291a68462089bdfc (patch) | |
tree | 457f5e653ac27bab771ca80b592036c3b0d69692 | |
parent | c8c52ad3c5ff5974688115b9a014efb3db94a434 (diff) | |
download | gitlab-ce-f3a3bc887ba44dbaac67238b291a68462089bdfc.tar.gz |
etag caching
-rw-r--r-- | app/controllers/concerns/notes_actions.rb | 1 | ||||
-rw-r--r-- | app/models/concerns/issuable.rb | 4 | ||||
-rw-r--r-- | app/models/concerns/noteable.rb | 22 | ||||
-rw-r--r-- | app/models/note.rb | 13 | ||||
-rw-r--r-- | app/models/resource_label_event.rb | 14 | ||||
-rw-r--r-- | app/services/resource_events/change_labels_service.rb | 1 |
6 files changed, 25 insertions, 30 deletions
diff --git a/app/controllers/concerns/notes_actions.rb b/app/controllers/concerns/notes_actions.rb index 68f152cbfec..63f1e89fe26 100644 --- a/app/controllers/concerns/notes_actions.rb +++ b/app/controllers/concerns/notes_actions.rb @@ -18,7 +18,6 @@ module NotesActions notes = notes_finder.execute .inc_relations_for_view - # FIXME: created_after notes = ResourceEvents::MergeIntoNotesService.new(noteable, last_fetched_at: current_fetched_at).execute(notes) notes = prepare_notes_for_rendering(notes) diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb index e8072145551..9396cf342b3 100644 --- a/app/models/concerns/issuable.rb +++ b/app/models/concerns/issuable.rb @@ -109,10 +109,6 @@ module Issuable false end - def etag_caching_enabled? - false - end - def has_multiple_assignees? assignees.count > 1 end diff --git a/app/models/concerns/noteable.rb b/app/models/concerns/noteable.rb index ce778eae271..a53ba805dc1 100644 --- a/app/models/concerns/noteable.rb +++ b/app/models/concerns/noteable.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true module Noteable + prepend EE::Noteable + # Names of all implementers of `Noteable` that support resolvable notes. RESOLVABLE_TYPES = %w(MergeRequest).freeze @@ -82,4 +84,24 @@ module Noteable def lockable? [MergeRequest, Issue].include?(self.class) end + + def etag_caching_enabled? + false + end + + def expire_note_etag_cache + return unless discussions_rendered_on_frontend? + return unless etag_caching_enabled? + + Gitlab::EtagCaching::Store.new.touch(note_etag_key) + end + + def note_etag_key + # FIXME - check Gitlab::Routing.url_helpers is available + Gitlab::Routing.url_helpers.project_noteable_notes_path( + project, + target_type: self.class.name.underscore, + target_id: id + ) + end end diff --git a/app/models/note.rb b/app/models/note.rb index 2e343b8f9f8..8f090cc31e6 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -389,18 +389,7 @@ class Note < ActiveRecord::Base end def expire_etag_cache - return unless noteable&.discussions_rendered_on_frontend? - return unless noteable&.etag_caching_enabled? - - Gitlab::EtagCaching::Store.new.touch(etag_key) - end - - def etag_key - Gitlab::Routing.url_helpers.project_noteable_notes_path( - project, - target_type: noteable_type.underscore, - target_id: noteable_id - ) + noteable&.expire_note_etag_cache end def touch(*args) diff --git a/app/models/resource_label_event.rb b/app/models/resource_label_event.rb index 48f9ecc3bbf..ca26082982d 100644 --- a/app/models/resource_label_event.rb +++ b/app/models/resource_label_event.rb @@ -49,18 +49,6 @@ class ResourceLabelEvent < ActiveRecord::Base end def expire_etag_cache - return unless issuable&.discussions_rendered_on_frontend? - return unless issuable&.etag_caching_enabled? - - Gitlab::EtagCaching::Store.new.touch(etag_key) - end - - # FIXME: override for epic - def etag_key - Gitlab::Routing.url_helpers.project_noteable_notes_path( - project, - target_type: 'issue', - target_id: issuable.id - ) + issuable.expire_note_etag_cache end end diff --git a/app/services/resource_events/change_labels_service.rb b/app/services/resource_events/change_labels_service.rb index 950cc8d7f46..039d6e2ebad 100644 --- a/app/services/resource_events/change_labels_service.rb +++ b/app/services/resource_events/change_labels_service.rb @@ -23,6 +23,7 @@ module ResourceEvents end Gitlab::Database.bulk_insert(ResourceLabelEvent.table_name, labels) + resource.expire_note_etag_cache end private |