Skip to content

Commit 0c784c2

Browse files
committed
Revert "Do not loop through details unless embed links exist"
This reverts commit 0c78953. We previously introduced an optimisation to reduce the amount of text parsing needed for embedded content links, however this resulted in a database query instead of the text parsing. For some pages (e.g. the Prime Minister page), this resulted in GraphQL reequests making 176 queries instead of 15, which was slower than parsing the text. Reverting the change, to restore the previous behaviour.
1 parent 11421aa commit 0c784c2

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

app/presenters/content_embed_presenter.rb

+5-9
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ def initialize(edition)
55
end
66

77
def render_embedded_content(details)
8-
return details unless target_content_ids
9-
108
details.each_pair do |field, value|
119
next if value.blank?
1210

@@ -18,15 +16,13 @@ def render_embedded_content(details)
1816

1917
private
2018

21-
def target_content_ids
22-
@target_content_ids ||= @edition
23-
.links
24-
.where(link_type: "embed")
25-
.pluck(:target_content_id)
26-
end
27-
2819
def embedded_editions
2920
@embedded_editions ||= begin
21+
target_content_ids = @edition
22+
.links
23+
.where(link_type: "embed")
24+
.pluck(:target_content_id)
25+
3026
embedded_edition_ids = ::Queries::GetEditionIdsWithFallbacks.call(
3127
target_content_ids,
3228
locale_fallback_order: [@edition.locale, Edition::DEFAULT_LOCALE].uniq,

0 commit comments

Comments
 (0)