Don't cache related actions in investments view
We've experienced some caching issues with this code for years. We've fixed some of them in commits9979b5399and3645c333a, but we're still running into other issues. In order to really cache this section, we'd need to cache: * Whether or not the investment should show the aside and vote/support buttons (we could do it by caching its budget) * Whether its budget is balloting or finished (we could do it by caching its budget) * Whether the current user is following the investment * Whether the `remove_investments_supports` feature is enabled * Whether the `community` feature is enabled * The value of the `org_name` setting * The value of the `twitter_handle` setting We weren't caching all these elements, meaning that (for instance), we didn't display the button to vote when a budget moved into the voting phase if we had already cached this section without the button. And chances are the list is incomplete. So, instead of trying to take into account every single possible factor that should make us expire the cache, we're restricting the cache so it only affects the content of the investment. This is similar to what we do in the investments index, where we cache the content of the investment but we don't cache the vote/support buttons.
This commit is contained in:
@@ -7,21 +7,18 @@
|
|||||||
og_image_url: (investment.image.present? ? polymorphic_path(investment.image.variant(:thumb)) : nil) %>
|
og_image_url: (investment.image.present? ? polymorphic_path(investment.image.variant(:thumb)) : nil) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
<section class="budget-investment-show" id="<%= dom_id(investment) %>">
|
||||||
|
<div class="row">
|
||||||
<% cache [locale_and_user_status(investment),
|
<% cache [locale_and_user_status(investment),
|
||||||
investment,
|
investment,
|
||||||
investment.author,
|
investment.author,
|
||||||
Flag.flagged?(current_user, investment),
|
Flag.flagged?(current_user, investment)] do %>
|
||||||
investment.followed_by?(current_user),
|
|
||||||
feature?(:remove_investments_supports),
|
|
||||||
current_user&.voted_for?(investment)] do %>
|
|
||||||
<section class="budget-investment-show" id="<%= dom_id(investment) %>">
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<div class="small-12 medium-9 column">
|
<div class="small-12 medium-9 column">
|
||||||
<%= back_link_to budget_investments_path(investment.budget, heading_id: investment.heading) %>
|
<%= back_link_to budget_investments_path(investment.budget, heading_id: investment.heading) %>
|
||||||
|
|
||||||
<%= render "/budgets/investments/investment_detail", investment: investment %>
|
<%= render "/budgets/investments/investment_detail", investment: investment %>
|
||||||
</div>
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<aside class="small-12 medium-3 column">
|
<aside class="small-12 medium-3 column">
|
||||||
<%= render "/budgets/investments/author_actions", investment: investment %>
|
<%= render "/budgets/investments/author_actions", investment: investment %>
|
||||||
@@ -125,4 +122,3 @@
|
|||||||
</aside>
|
</aside>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<% end %>
|
|
||||||
|
|||||||
Reference in New Issue
Block a user