Open
Conversation
woopsn
reviewed
Apr 1, 2025
| Rails.cache.fetch("#{cache_key_with_version}/related_content") do | ||
| RelatedContent.as_hash(related_content_url) | ||
| end | ||
| end |
Member
There was a problem hiding this comment.
It may be good to let OpenURI::HTTPError bubble up out of RelatedContent and move the rescue to this method now, so that the {} value doesn't get cached in that case.
Member
Author
There was a problem hiding this comment.
Ended up addressing this by changing RelatedContent to return nil in all fail states & used the skip_nil option on cache.fetch to avoid caching nil
| <h4>Related Content</h4> | ||
| <%= link_to action_page.related_content_url do %> | ||
| <div class="image"> | ||
| <%= image_tag(action_page.related_content.image) %> |
Member
There was a problem hiding this comment.
The title/image methods in this view are called on a hash now so it needed some slight changes:
<h4>Related Content</h4>
<%= link_to action_page.related_content_url do %>
<div class="image">
- <%= image_tag(action_page.related_content.image) %>
+ <%= image_tag(action_page.related_content[:image_url]) %>
</div>
- <h5><%= action_page.related_content.title %></h5>
+ <h5><%= action_page.related_content[:title] %></h5>
<% end %>
</div>
<div class="desc-text">
@@ -14,8 +14,8 @@
<h4>Related Content</h4>
<%= link_to action_page.related_content_url do %>
<div class="image">
- <%= image_tag(action_page.related_content.image) %>
+ <%= image_tag(action_page.related_content[:image_url]) %>
</div>
- <h5><%= action_page.related_content.title %></h5>
+ <h5><%= action_page.related_content[:title] %></h5>
<% end %>
</div>8a7e2c1 to
7ced577
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The diff is quite large due to including all the files from a single deeplinks page as a test fixture -- this is not that big of a PR!
Cache related content on action pages. Currently this cache will become stale only when the action page is updated; we could add an expiry time instead if that's what we'd prefer or decide we need (I think blogposts that get attached to actions are usually not changing by the time they're added to an action, but that assumption could be wrong).