Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use rummager results for image_urls #1042

Merged
merged 7 commits into from
Aug 14, 2018
Merged

Conversation

sihugh
Copy link
Contributor

@sihugh sihugh commented Aug 10, 2018

This eliminates up to three calls to content store for each page's navigation.

To do this we need to add image_url to the fields that rummager returns.

We can remove the alt text for images that are links because the link text is more relevant (and is preferred by browsers anyway).

We then need a default image in case the content doesn't have an image (not all do).

After rebasing on top of #1043 and #1032 it became clear that we can remove some things from the news_and_communications and services as they don't need to have content split into promoted and tagged content any more as they only display it in one form now.

I've therefore removed the promoted sections from these presenters which allows us to simplify some things and delete a bunch of code.


https://government-frontend-pr-1042.herokuapp.com/apply-apprenticeship

@benthorner benthorner temporarily deployed to government-frontend-pr-1042 August 10, 2018 16:29 Inactive
alt: document_image["alt_text"],
context: document_image["context"]
def format_document_data(documents, data_category: nil)
documents.each.with_index(1).map do |document, index|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to double check the Ruby API documentation to confirm that 1 is an offset. Could we extract this to provide a little more context?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -2,6 +2,8 @@ module Supergroups
class NewsAndCommunications < Supergroup
attr_reader :content

PLACEHOLDER_IMAGE = "https://assets.publishing.service.gov.uk/government/assets/placeholder.jpg".freeze
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use Plek to make this environment specific?

PLACEHOLDER_IMAGE = URI::HTTPS.build(host: Plek.current.public_asset_host, path: '/government/assets/placeholder.jpg').freeze

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good idea, thanks. 👍

@sihugh sihugh force-pushed the dont-use-content-store-for-images branch from df45108 to 78a44e0 Compare August 14, 2018 12:40
@benthorner benthorner temporarily deployed to government-frontend-pr-1042 August 14, 2018 12:40 Inactive
sihugh added 6 commits August 14, 2018 13:46
We don't need this at present because the image is part of a link.  The link
text overrides the alt text in this instance so we're not reducing any
accessibility.

This allows us to use the recently added image_url search field.
This allows us to reuse small bits of functionality
This ensures that our analytics will be consistent between sections.
This eliminates up to three calls to content store for each page's navigation.

To do this we need to add image_url to the fields that rummager returns.

We then need a default image in case the content doesn't have an image (not
all do).
We may want to add Welsh and other translations for these later.
@sihugh sihugh force-pushed the dont-use-content-store-for-images branch from 78a44e0 to 74244e7 Compare August 14, 2018 15:23
@benthorner benthorner temporarily deployed to government-frontend-pr-1042 August 14, 2018 15:23 Inactive
We're now only retrieving 3 items per section so we can delete a lot of code
from the news_and_communications and services presenters and get them to return
an array of results rather than hashes.

This allows us to get them to behave a bit more like the other presenters.
@sihugh
Copy link
Contributor Author

sihugh commented Aug 14, 2018

I've updated this and rebased after a couple of merges. It's worth sticking ?w=1 on the end of the URL when looking at the diff as Github's got a little confused about what is a change in a couple of places.

@sihugh sihugh merged commit 4314364 into master Aug 14, 2018
@sihugh sihugh deleted the dont-use-content-store-for-images branch August 14, 2018 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants