diff --git a/app/controllers/documents_controller.rb b/app/controllers/documents_controller.rb index a1f5b731..f484adfa 100644 --- a/app/controllers/documents_controller.rb +++ b/app/controllers/documents_controller.rb @@ -12,6 +12,10 @@ class DocumentsController < ApplicationController before_action :set_navbar_actions, except: [:edit, :plaintext] before_action :set_footer_visibility, only: [:edit] + # Skip UI-heavy calls for API endpoints + skip_before_action :cache_most_used_page_information, only: [:update] + skip_before_action :cache_forums_unread_counts, only: [:update] + # TODO: verify_user_can_read, verify_user_can_edit, etc before_actions instead of inlining them before_action :cache_linkable_content_for_each_content_type, only: [:edit] diff --git a/app/models/concerns/has_image_uploads.rb b/app/models/concerns/has_image_uploads.rb index a59df6d2..9327744a 100644 --- a/app/models/concerns/has_image_uploads.rb +++ b/app/models/concerns/has_image_uploads.rb @@ -17,7 +17,14 @@ module HasImageUploads end def random_image_including_private(format: :medium) - image_uploads.sample.try(:src, format).presence || "card-headers/#{self.class.name.downcase.pluralize}.jpg" + @random_image_including_private_cache ||= {} + key = self.class.name + self.id.to_s + return @random_image_including_private_cache[key] if @random_image_including_private_cache.key?(key) + + result = image_uploads.sample.try(:src, format).presence || "card-headers/#{self.class.name.downcase.pluralize}.jpg" + @random_image_including_private_cache[key] = result + + result end def first_public_image(format: :medium) diff --git a/app/models/page_types/creature.rb b/app/models/page_types/creature.rb index 61925486..19ad5da3 100644 --- a/app/models/page_types/creature.rb +++ b/app/models/page_types/creature.rb @@ -20,7 +20,7 @@ class Creature < ApplicationRecord include Serendipitous::Concern include Authority::Abilities - self.authorizer_name = 'ExtendedContentAuthorizer' + self.authorizer_name = 'CoreContentAuthorizer' # Locations relates :habitats, with: :wildlifeships diff --git a/app/views/main/dashboard.html.erb b/app/views/main/dashboard.html.erb index 692d507d..4e3b32ff 100644 --- a/app/views/main/dashboard.html.erb +++ b/app/views/main/dashboard.html.erb @@ -186,8 +186,10 @@ <% end %>