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
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
357 changes: 144 additions & 213 deletions secret-squirrel.js

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions server/lib/enrich/article.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ module.exports = exports = function article(content, format) {

content.hasGraphics = Boolean(content.contentStats && content.contentStats.graphics);

// Currently embeds can have more than one item for each picture - for different screen sizes
// We are assuming that canBeSyndicated is the same for all sizes of a picture
// We are asking if ALL Graphics can be syndicated, which means as long as at least one item
// can't be, the answer to this is 'no'
const atLeastOneGraphicCantBeShared = content.embeds && content.embeds.filter(embed => embed && embed.type.endsWith('Graphic')).some(item => item.canBeSyndicated !== 'yes');
AniaMakes marked this conversation as resolved.
Show resolved Hide resolved
AniaMakes marked this conversation as resolved.
Show resolved Hide resolved

content.canAllGraphicsBeSyndicated = Boolean(atLeastOneGraphicCantBeShared);
AniaMakes marked this conversation as resolved.
Show resolved Hide resolved
AniaMakes marked this conversation as resolved.
Show resolved Hide resolved

if (content.bodyHTML) {
content.document = formatArticleXML(`<body>${content.bodyHTML}</body>`);

Expand Down
3 changes: 3 additions & 0 deletions server/lib/resolve/canAllGraphicsBeSyndicated.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';

module.exports = exports = item => item;
3 changes: 3 additions & 0 deletions server/lib/resolve/hasGraphics.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';

module.exports = exports = item => item;
2 changes: 2 additions & 0 deletions server/lib/resolve/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
'use strict';

exports.id = require('./id');
exports.canAllGraphicsBeSyndicated = require('./canAllGraphicsBeSyndicated');
exports.canDownload = require('./canDownload');
exports.canBeSyndicated = require('./canBeSyndicated');
exports.downloaded = require('./downloaded');
exports.embargoPeriod = require('./embargoPeriod');
exports.hasGraphics = require('./hasGraphics');
AniaMakes marked this conversation as resolved.
Show resolved Hide resolved
exports.lang = require('./lang');
exports.publishedDate = require('./publishedDate');
exports.publishedDateDisplay = require('./publishedDateDisplay');
Expand Down
5 changes: 5 additions & 0 deletions server/lib/syndicate-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,10 @@ function tidy(item, includeBody) {
delete item.fileName;
}

if (item.type !== 'article'){
delete item.canAllGraphicsBeSyndicated;
delete item.hasGraphics;
}

return item;
}
498 changes: 384 additions & 114 deletions test/fixtures/content/42ad255a-99f9-11e7-b83c-9588e51488a0.json

Large diffs are not rendered by default.

226 changes: 139 additions & 87 deletions test/fixtures/content/a1af0574-eafb-41bd-aa4f-59aa2cd084c2.json

Large diffs are not rendered by default.

171 changes: 119 additions & 52 deletions test/fixtures/content/b16fce7e-3c92-48a3-ace0-d1af3fce71af.json
Original file line number Diff line number Diff line change
@@ -1,54 +1,50 @@
{
"id": "b16fce7e-3c92-48a3-ace0-d1af3fce71af",
"webUrl": "https://www.ft.com/video/b16fce7e-3c92-48a3-ace0-d1af3fce71af",
"webUrl": "https://www.ft.com/content/b16fce7e-3c92-48a3-ace0-d1af3fce71af",
"title": "Mental health and the gig economy",
"alternativeTitles": {},
"standfirst": "Flexibility is good for workers, but can bring health problems",
"provenance": [
"http://api.ft.com/internalcontent/b16fce7e-3c92-48a3-ace0-d1af3fce71af"
"https://api.ft.com/internalcontent/b16fce7e-3c92-48a3-ace0-d1af3fce71af"
],
"byline": "Graphics by Aslan Livingstone-Ra. Produced by Seb Morton-Clark and Emma Boyde.",
"standfirst": "Flexibility is good for workers, but can bring health problems",
"publishedDate": "2017-09-13T12:15:43.662Z",
"firstPublishedDate": "2017-09-13T12:15:43.662Z",
"publishReference": "tid_eg4yqbdeuh",
"curatedRelatedContent": [
{
"apiUrl": "http://api.ft.com/content/749cb87e-6ca8-11e7-b9c7-15af748b60d0",
"id": "749cb87e-6ca8-11e7-b9c7-15af748b60d0"
"id": "749cb87e-6ca8-11e7-b9c7-15af748b60d0",
"apiUrl": "http://api.ft.com/content/749cb87e-6ca8-11e7-b9c7-15af748b60d0"
},
{
"apiUrl": "http://api.ft.com/content/dddf09c6-77a8-11e7-a3e8-60495fe6ca71",
"id": "dddf09c6-77a8-11e7-a3e8-60495fe6ca71"
"id": "dddf09c6-77a8-11e7-a3e8-60495fe6ca71",
"apiUrl": "http://api.ft.com/content/dddf09c6-77a8-11e7-a3e8-60495fe6ca71"
},
{
"apiUrl": "http://api.ft.com/content/d9d59684-6ca3-11e7-bfeb-33fe0c5b7eaa",
"id": "d9d59684-6ca3-11e7-bfeb-33fe0c5b7eaa"
"id": "d9d59684-6ca3-11e7-bfeb-33fe0c5b7eaa",
"apiUrl": "http://api.ft.com/content/d9d59684-6ca3-11e7-bfeb-33fe0c5b7eaa"
},
{
"apiUrl": "http://api.ft.com/content/398df8c0-67b1-11e7-8526-7b38dcaef614",
"id": "398df8c0-67b1-11e7-8526-7b38dcaef614"
"id": "398df8c0-67b1-11e7-8526-7b38dcaef614",
"apiUrl": "http://api.ft.com/content/398df8c0-67b1-11e7-8526-7b38dcaef614"
}
],
"containedIn": [],
"canBeDistributed": "yes",
"canBeSyndicated": "yes",
"comments": {
"enabled": false
},
"standout": { },
"standout": {},
"realtime": false,
"originatingParty": "FT",
"_lastUpdatedDateTime": "2017-09-13T13:16:07.651Z",
"_lastUpdatedDateTime": "2020-09-02T22:31:44.236Z",
"_lastUpdatedVersion": "fc268c176f0ba875ad15b6671e797dda89a9cc3b",
"type": "video",
"description": "Workers appreciate the flexibility of the gig economy, but isolation, long hours and performance assessment by an algorithm are contributing to mental health problems",
"bodyHTML": "<p>[MUSIC PLAYING] </p><p>Everyone is talking about the gig economy. But what exactly are they talking about? Is it big or small, exciting or terrifying? Good for you health or bad for it? </p><p>The first thing to know about the gig economy is that not everyone actually agrees on what it means. As the name suggests, it's about people who earn money from doing a series of gigs or tasks. But some people use that term to apply to everyone who works independently, including lawyers and plumbers, but, of course, the notion of working for yourself is nothing new. </p><p>What is new is the invention of digital platforms that connect customers with workers to perform tasks on demand. That task could be to do someone's ironing, translate a document from Arabic to English, deliver a pizza, or drive someone home from a nightclub. There are a host of gig economy platforms, from Upwork or HourlyNerd, for tasks that are done online, to Uber and Deliveroo, for tasks that are done in person. </p><p>The uniting feature is that they match workers to customers, and they use their technology to facilitate the payment, while taking a cut for themselves. They say they're intermediaries, not employers. Others disagree. That's a question being thrashed out in courts in the US, the UK, and elsewhere. </p><p>If you live in a city teeming with Ubers, you might think the gig economy is huge already, but, actually, the number working in it is still pretty small, but it is significant. In the UK, one think tank says about 3 and 1/2% of the workforce are in the gig economy. That's about the same number as work for the National Health Service, the UK'S largest employer. </p><p>This is a growing army of workers without work places, colleagues, or bosses. What does that mean for their health and safety? </p><p>In some ways, it could be positive. The gig economy is based on the idea of working whenever you want. Having a job where you can easily nip out to deal with something personal, studies show that's one of the best indicators for high well-being. </p><p>But some health experts are worried. Flexibility might be good for your health, but loneliness and isolation are bad for it. </p><p>Gig workers don't have line managers to keep an eye out for them. Instead, their regular contact is with an algorithm that doesn't know how they're feeling today, or what personal problems might have cropped up. The algorithm just sends them tasks and monitors their performance. </p><p>Some algorithms also deactivate workers from their platforms, if there are performance issues. That can create pressure. And when the platform sets the fee per task, some workers feel they can only increase their earnings by working ever longer hours. </p><p>Driving or cycling and traffic can be dangerous at the best of times, let alone when you're tired and stressed. </p><p>For health experts, one thing is clear, there's an urgent need to investigate the benefits and the risks of this new world of work. </p><p>[MUSIC PLAYING] </p>",
"bodyText": "[MUSIC PLAYING]\n\nEveryone is talking about the gig economy. But what exactly are they talking about? Is it big or small, exciting or terrifying? Good for you health or bad for it?\n\nThe first thing to know about the gig economy is that not everyone actually agrees on what it means. As the name suggests, it's about people who earn money from doing a series of gigs or tasks. But some people use that term to apply to everyone who works independently, including lawyers and plumbers, but, of course, the notion of working for yourself is nothing new.\n\nWhat is new is the invention of digital platforms that connect customers with workers to perform tasks on demand. That task could be to do someone's ironing, translate a document from Arabic to English, deliver a pizza, or drive someone home from a nightclub. There are a host of gig economy platforms, from Upwork or HourlyNerd, for tasks that are done online, to Uber and Deliveroo, for tasks that are done in person.\n\nThe uniting feature is that they match workers to customers, and they use their technology to facilitate the payment, while taking a cut for themselves. They say they're intermediaries, not employers. Others disagree. That's a question being thrashed out in courts in the US, the UK, and elsewhere.\n\nIf you live in a city teeming with Ubers, you might think the gig economy is huge already, but, actually, the number working in it is still pretty small, but it is significant. In the UK, one think tank says about 3 and 1/2% of the workforce are in the gig economy. That's about the same number as work for the National Health Service, the UK'S largest employer.\n\nThis is a growing army of workers without work places, colleagues, or bosses. What does that mean for their health and safety?\n\nIn some ways, it could be positive. The gig economy is based on the idea of working whenever you want. Having a job where you can easily nip out to deal with something personal, studies show that's one of the best indicators for high well-being.\n\nBut some health experts are worried. Flexibility might be good for your health, but loneliness and isolation are bad for it.\n\nGig workers don't have line managers to keep an eye out for them. Instead, their regular contact is with an algorithm that doesn't know how they're feeling today, or what personal problems might have cropped up. The algorithm just sends them tasks and monitors their performance.\n\nSome algorithms also deactivate workers from their platforms, if there are performance issues. That can create pressure. And when the platform sets the fee per task, some workers feel they can only increase their earnings by working ever longer hours.\n\nDriving or cycling and traffic can be dangerous at the best of times, let alone when you're tired and stressed.\n\nFor health experts, one thing is clear, there's an urgent need to investigate the benefits and the risks of this new world of work.\n\n[MUSIC PLAYING]",
"url": "https://www.ft.com/video/b16fce7e-3c92-48a3-ace0-d1af3fce71af",
"mainImage": {
"title": "mas-gig.png",
"description": "",
"url": "http://prod-upp-image-read.ft.com/7156ce33-3a5a-43b9-83ce-2206337d2784",
"width": 2048,
"height": 1152,
"ratio": 1.7777777777777777,
"aspectRatio": 0.5625
},
"attachments": [
{
"url": "https://next-media-api.ft.com/renditions/15053038942430/640x360.mp4",
Expand Down Expand Up @@ -79,60 +75,131 @@
"url": "https://next-media-api.ft.com/captions/15053038942430.vtt"
}
],
"containedIn": [ ],
"relativeUrl": "/video/b16fce7e-3c92-48a3-ace0-d1af3fce71af",
"mainImage": {
"url": "http://prod-upp-image-read.ft.com/7156ce33-3a5a-43b9-83ce-2206337d2784",
"title": "mas-gig.png",
"description": "",
"width": 2048,
"height": 1152,
"ratio": 1.77778,
"aspectRatio": 0.5625
},
"annotations": [
{
"apiUrl": "http://api.ft.com/things/852939c8-859c-361e-8514-f82f6c041580",
"directType": "http://www.ft.com/ontology/Section",
"id": "852939c8-859c-361e-8514-f82f6c041580",
"apiUrl": "http://api.ft.com/things/596c35ec-bdb3-409a-83fb-717ecd3dc029",
"directType": "http://www.ft.com/ontology/Genre",
"id": "596c35ec-bdb3-409a-83fb-717ecd3dc029",
"predicate": "http://www.ft.com/ontology/classification/isClassifiedBy",
"prefLabel": "Companies",
"type": "SECTION",
"prefLabel": "Explainer",
"type": "GENRE",
"types": [
"http://www.ft.com/ontology/core/Thing",
"http://www.ft.com/ontology/concept/Concept",
"http://www.ft.com/ontology/classification/Classification",
"http://www.ft.com/ontology/Section"
"http://www.ft.com/ontology/Genre"
],
"url": "https://www.ft.com/companies",
"preposition": "in",
"relativeUrl": "/companies"
"preposition": "",
"url": "https://www.ft.com/explainer",
"relativeUrl": "/explainer"
},
{
"apiUrl": "http://api.ft.com/things/b2fa15d1-56b4-3767-8bcd-595b23a5ff22",
"directType": "http://www.ft.com/ontology/Genre",
"id": "b2fa15d1-56b4-3767-8bcd-595b23a5ff22",
"apiUrl": "http://api.ft.com/things/c47f4dfc-6879-4e95-accf-ca8cbe6a1f69",
"directType": "http://www.ft.com/ontology/Topic",
"id": "c47f4dfc-6879-4e95-accf-ca8cbe6a1f69",
"predicate": "http://www.ft.com/ontology/classification/isClassifiedBy",
"prefLabel": "Explainer",
"type": "GENRE",
"prefLabel": "Companies",
"type": "TOPIC",
"types": [
"http://www.ft.com/ontology/core/Thing",
"http://www.ft.com/ontology/concept/Concept",
"http://www.ft.com/ontology/classification/Classification",
"http://www.ft.com/ontology/Genre"
"http://www.ft.com/ontology/Topic"
],
"url": "https://www.ft.com/stream/b2fa15d1-56b4-3767-8bcd-595b23a5ff22",
"preposition": "",
"relativeUrl": "/stream/b2fa15d1-56b4-3767-8bcd-595b23a5ff22"
"preposition": "on",
"url": "https://www.ft.com/companies",
"relativeUrl": "/companies"
}
],
"genreConcept": {
"apiUrl": "http://api.ft.com/things/596c35ec-bdb3-409a-83fb-717ecd3dc029",
"directType": "http://www.ft.com/ontology/Genre",
"id": "596c35ec-bdb3-409a-83fb-717ecd3dc029",
"predicate": "http://www.ft.com/ontology/classification/isClassifiedBy",
"prefLabel": "Explainer",
"type": "GENRE",
"types": [
"http://www.ft.com/ontology/core/Thing",
"http://www.ft.com/ontology/concept/Concept",
"http://www.ft.com/ontology/classification/Classification",
"http://www.ft.com/ontology/Genre"
],
"preposition": "",
"url": "https://www.ft.com/explainer",
"relativeUrl": "/explainer"
},
"authorConcepts": [],
"design": {
"theme": "basic",
"layout": "default"
},
"displayConcept": {
"apiUrl": "http://api.ft.com/things/852939c8-859c-361e-8514-f82f6c041580",
"directType": "http://www.ft.com/ontology/Section",
"id": "852939c8-859c-361e-8514-f82f6c041580",
"apiUrl": "http://api.ft.com/things/c47f4dfc-6879-4e95-accf-ca8cbe6a1f69",
"directType": "http://www.ft.com/ontology/Topic",
"id": "c47f4dfc-6879-4e95-accf-ca8cbe6a1f69",
"predicate": "http://www.ft.com/ontology/classification/isClassifiedBy",
"prefLabel": "Companies",
"type": "SECTION",
"type": "TOPIC",
"types": [
"http://www.ft.com/ontology/core/Thing",
"http://www.ft.com/ontology/concept/Concept",
"http://www.ft.com/ontology/classification/Classification",
"http://www.ft.com/ontology/Section"
"http://www.ft.com/ontology/Topic"
],
"preposition": "on",
"url": "https://www.ft.com/companies",
"preposition": "in",
"relativeUrl": "/companies"
"relativeUrl": "/companies",
"isDisplayTag": false
},
"genreConcept": null,
"authorConcepts": [ ]
"teaser": {
"id": "b16fce7e-3c92-48a3-ace0-d1af3fce71af",
"url": "https://www.ft.com/video/b16fce7e-3c92-48a3-ace0-d1af3fce71af",
"relativeUrl": "/video/b16fce7e-3c92-48a3-ace0-d1af3fce71af",
"type": "video",
"indicators": {
"isColumn": false,
"isOpinion": false,
"isScoop": false,
"isExclusive": false,
"isEditorsChoice": false,
"accessLevel": "subscribed"
},
"metaPrefixText": "Explainer",
"metaSuffixText": "3 min",
"metaLink": {
"id": "c47f4dfc-6879-4e95-accf-ca8cbe6a1f69",
"predicate": "http://www.ft.com/ontology/classification/isClassifiedBy",
"prefLabel": "Companies",
"type": "TOPIC",
"url": "https://www.ft.com/companies",
"relativeUrl": "/companies"
},
"metaAltLink": null,
"title": "Mental health and the gig economy",
"standfirst": "Flexibility is good for workers, but can bring health problems",
"altStandfirst": null,
"publishedDate": "2017-09-13T12:15:43.662Z",
"firstPublishedDate": "2017-09-13T12:15:43.662Z",
"image": {
"url": "http://prod-upp-image-read.ft.com/7156ce33-3a5a-43b9-83ce-2206337d2784",
"width": 2048,
"height": 1152
},
"video": {
"url": "https://next-media-api.ft.com/renditions/15053038942430/640x360.mp4",
"width": 640,
"height": 360,
"duration": 178943,
"codec": "h264",
"mediaType": "video/mp4"
}
}
}
Loading