Skip to content

Commit

Permalink
Merge pull request #1913 from MushroomObserver/nimmo-russian-doll
Browse files Browse the repository at this point in the history
Disable cache for matrix boxes
  • Loading branch information
nimmolo committed Feb 16, 2024
2 parents 4f5f4ea + 55ab4f3 commit 0e94b1f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
14 changes: 9 additions & 5 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1491,12 +1491,16 @@ def find_objects(query, args)

# If caching, only uncached objects need to eager_load the includes
def objects_with_only_needed_eager_loads(query, include)
user = User.current ? "logged_in" : "no_user"
locale = I18n.locale
# user = User.current ? "logged_in" : "no_user"
# locale = I18n.locale
objects_simple = query.paginate(@pages)
ids_to_eager_load = objects_simple.reject do |obj|
object_fragment_exist?(obj, user, locale)
end.pluck(:id)

# Temporarily disabling cached matrix boxes: eager load everything
ids_to_eager_load = objects_simple

# ids_to_eager_load = objects_simple.reject do |obj|
# object_fragment_exist?(obj, user, locale)
# end.pluck(:id)
# now get the heavy loaded instances:
objects_eager = query.model.where(id: ids_to_eager_load).includes(include)
# our Array extension: collates new instances with old, in original order
Expand Down
5 changes: 3 additions & 2 deletions app/helpers/matrix_box_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@ def matrix_table(**args, &block)
].safe_join
end

# Temporarily disabled to fix Russian Doll issues.
def render_cached_matrix_boxes(objects, locals)
# matrix box has one version except langs.
# css hides image vote ui when body.no-user
objects.each do |object|
cache(object) do
# cache(object) do
concat(render(partial: "shared/matrix_box",
locals: { object: object }.merge(locals)))
end
# end
end
end

Expand Down

0 comments on commit 0e94b1f

Please sign in to comment.