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

ACC-622 Enhance response to include info about Graphic syndication #235

Merged
merged 8 commits into from
Sep 17, 2020

Conversation

AniaMakes
Copy link
Contributor

Ticket

https://financialtimes.atlassian.net/browse/ACC-622

Things done in this PR

  • updated some fixtures to their 2020 state (fixtures are used for mocks in tests and have been stuck in their 2017 version). Not all of the fixtures have been updated (see Enriching Audio / Podcast content does not work with 2020 ES results.  #234 ) because it was out of scope for this ticket.
  • the endpoint now returns hasGraphics boolean and canAllGraphicsBeSyndicated boolean for article only

Shortfalls

Currently we don't have an article that has canAllGraphicsBeSyndicated true, and I'm not sure what's the practicality of having a test for something that is different in prod.

@AniaMakes AniaMakes requested a review from a team September 7, 2020 11:24
const countOfGraphics = content.contentStats && content.contentStats.graphics && content.contentStats.graphics;
const countOfSharableGraphics = content.embeds ? content.embeds.filter(embed => embed && embed.type.endsWith('Graphic')).filter(embed => embed.canBeSyndicated === 'yes').length : 0;

content.canAllGraphicsBeSyndicated = countOfGraphics > 0 ? countOfSharableGraphics < countOfGraphics : false;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Decided to go with false rather than null because that way I can have expect a boolean in tests.

Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't the following achieve the same purpose in a simpler way 🤔 ?

Suggested change
content.canAllGraphicsBeSyndicated = countOfGraphics > 0 ? countOfSharableGraphics < countOfGraphics : false;
const canAllGraphicsBeSyndicated = countOfGraphics === countOfSharableGraphics;

@@ -70,5 +70,10 @@ function tidy(item, includeBody) {
delete item.fileName;
}

if (item.hasGraphics === undefined){
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This bit removes the keys and their undefined values from non-article types.

server/lib/syndicate-content.js Outdated Show resolved Hide resolved
Comment on lines 36 to 43
const countOfGraphics = content.contentStats && content.contentStats.graphics && content.contentStats.graphics;
const countOfSharableGraphics = content.embeds ? content.embeds.filter(embed => embed && embed.type.endsWith('Graphic')).filter(embed => embed.canBeSyndicated === 'yes').length : 0;

content.canAllGraphicsBeSyndicated = countOfGraphics > 0 ? countOfSharableGraphics < countOfGraphics : false;

Copy link
Contributor

Choose a reason for hiding this comment

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

The embeds array contains all the images and graphics in all their different sizes. However, only the original (default size) images are used for syndication.

Should the graphics included in the content document be the source of truth for graphics in the article instead of the embeds array?

the embeds array would then be used as a map to check whether the graphics can be syndicated or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But that's what's there, with content.hasGraphics relying on contentStats.graphics count? (line 34)?

Then you have countOfGraphics (once again based on the contentStats). And countOfSharableGraphics which runs through the embeds to see how many can be syndicated.

It feels like you know something I don't - I'm just using an example ES article to figure this out 😅

Copy link
Contributor

Choose a reason for hiding this comment

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

contentStats.graphics is gotten from counting the number of graphics in the content document. embeds contains all graphics and their different sizes.

For example, the count for contentStats.graphics can be 1 and the count of graphics object in embeds could be 2 (graphics object for normal screens, graphics object for mobile screens).

Therefore, using that to count the number of sharable graphics can be inaccurate.

As we do not have any identifier for graphics object for normal screen (which is the graphics size we are using for syndication) in the embeds array.

We can

  1. Add a way to identify graphics objects for normal screens in the embeds array. That would require work on next-es-interface
  2. Get the graphics included in the content document, and look up the graphics object in the embeds array to check the canBeSyndicated property.

@AniaMakes AniaMakes temporarily deployed to ft-next-synd-endpoint-fispitk5 September 8, 2020 08:02 Inactive
@AniaMakes AniaMakes temporarily deployed to ft-next-synd-endpoint-fispitk5 September 8, 2020 08:23 Inactive
const countOfGraphics = content.contentStats && content.contentStats.graphics && content.contentStats.graphics;
const countOfSharableGraphics = content.embeds ? content.embeds.filter(embed => embed && embed.type.endsWith('Graphic')).filter(embed => embed.canBeSyndicated === 'yes').length : 0;

content.canAllGraphicsBeSyndicated = countOfGraphics > 0 ? countOfSharableGraphics < countOfGraphics : false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't the following achieve the same purpose in a simpler way 🤔 ?

Suggested change
content.canAllGraphicsBeSyndicated = countOfGraphics > 0 ? countOfSharableGraphics < countOfGraphics : false;
const canAllGraphicsBeSyndicated = countOfGraphics === countOfSharableGraphics;

server/lib/resolve/index.js Show resolved Hide resolved
@adgad adgad temporarily deployed to ft-next-synd-endpoint-jaazony6 September 16, 2020 13:25 Inactive
@AniaMakes AniaMakes temporarily deployed to ft-next-synd-endpoint-jaazony6 September 16, 2020 13:49 Inactive
server/lib/enrich/article.js Outdated Show resolved Hide resolved
server/lib/enrich/article.js Show resolved Hide resolved
@AniaMakes AniaMakes temporarily deployed to ft-next-synd-endpoint-jaazony6 September 16, 2020 14:30 Inactive
@AniaMakes AniaMakes merged commit 336fd86 into master Sep 17, 2020
@AniaMakes AniaMakes deleted the endpoint branch September 17, 2020 09:20
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.

6 participants