From 2eb50f510b1f8c1908760ab3950f3c05d5729715 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 3 Aug 2021 01:35:57 -0700 Subject: [PATCH] only query for contributable content if you're a contributor to any universes --- app/controllers/application_controller.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index f59ff07d..09f6ad5d 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -145,8 +145,16 @@ class ApplicationController < ActionController::Base @current_user_content.each do |page_type, content_list| # We already have our own list of content by the current user in @current_user_content, # so all we need to grab is pages in contributable universes - @linkables_raw[page_type] = @current_user_content[page_type] \ - + page_type.constantize.where(universe_id: @contributable_universe_ids) + @linkables_raw[page_type] = @current_user_content[page_type] + + if @contributable_universe_ids.any? + if page_type == Universe.name + @linkables_raw[page_type] += page_type.constantize.where(id: @contributable_universe_ids) + + else + @linkables_raw[page_type] += page_type.constantize.where(universe_id: @contributable_universe_ids) + end + end end # Finally, we want to sort our caches once so we don't need to sort them again anywhere else