impress/app/views/closet_lists/_closet_list.html.haml
Emi Matchu 583f3c712f High-level caching for closet lists
Okay, so I still don't know why rendering is just so slow (though
migrating away from item translations did help!), but I can at least
cache entire closet lists as a basic measure.

That way, the first user to see the latest version of a closet list
will still need just as much time to load it… but *only* the ones that
have changed since last time (rather than always the full page), and
then subsequent users get to reuse it too!

Should help a lot for high-traffic lists, which incidentally are likely
to be the big ones belonging to highly active traders!

One big change we needed to make was to extract the `user-owns` and
`user-wants` classes (which we use for trade matches for *the user
viewing the list right now*) out of the cached HTML, and apply them
after with Javascript instead. I always dislike moving stuff to JS, but
the wins here seem. truly very very good, all things considered!
2024-02-20 18:43:39 -08:00

32 lines
1.5 KiB
Text

.closet-list{'data-id' => closet_list.id, 'data-hangers-count' => closet_list.hangers.size, :id => "closet-list-#{closet_list.id}"}
%header
- if show_controls
= form_for [current_user, closet_list], :html => {:class => 'visibility-form'} do |f|
= f.select :visibility, closet_visibility_choices(:human_name)
= f.submit t('.submit')
= closet_visibility_descriptions(:list)
.closet-list-controls
= link_to t('.edit'), edit_user_closet_list_path(closet_list.user_id, closet_list)
= form_tag user_closet_list_path(closet_list.user_id, closet_list), :method => 'delete' do
= submit_tag t('.delete'), :confirm => closet_list_delete_confirmation(closet_list)
= form_tag user_closet_hangers_path(@user), method: :delete, class: 'remove-all' do
= hidden_field_tag :list_id, closet_list.id
= submit_tag t('.remove_all.submit'), confirm: t('.remove_all.confirm')
%button.select-all= t('.select_all')
%h4= closet_list.name
- if show_controls
= render partial: 'closet_lists/trading_neomail_warning', locals: {list: closet_list, user: @user}
-# Cachebuster comment: Updated downstream content at Feb 20 2024, 6:15pm
- cache closet_list do
.closet-list-content
- if closet_list.description?
= closet_list_description_format closet_list
.closet-list-hangers
- unless closet_list.hangers.empty?
= render_sorted_hangers(closet_list)
%span.empty-list= t('.empty')