Skip to content

Commit

Permalink
Merge pull request #146 from wellcomecollection/uid-pipeline
Browse files Browse the repository at this point in the history
Send uid to elastic
  • Loading branch information
davidpmccormick authored Oct 8, 2024
2 parents 097d2c1 + 38ba1f8 commit be59057
Show file tree
Hide file tree
Showing 24 changed files with 55 additions and 15 deletions.
3 changes: 3 additions & 0 deletions pipeline/src/indices/articles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ export const mappings = {
id: {
type: 'keyword',
},
uid: {
type: 'keyword',
},
display: {
type: 'object',
enabled: false,
Expand Down
3 changes: 3 additions & 0 deletions pipeline/src/indices/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ export const mappings = {
id: {
type: 'keyword',
},
uid: {
type: 'keyword',
},
isChildScheduledEvent: {
type: 'boolean',
},
Expand Down
3 changes: 3 additions & 0 deletions pipeline/src/transformers/article.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export const transformArticle = (
document: ArticlePrismicDocument
): ElasticsearchArticle => {
const { data, id, first_publication_date: firstPublicationDate } = document;
const uid = document.uid || undefined;
const primaryImage = data.promo?.[0]?.primary;

const image =
Expand Down Expand Up @@ -129,9 +130,11 @@ export const transformArticle = (

return {
id,
uid,
display: {
type: 'Article',
id,
uid,
title: asTitle(data.title),
caption,
format,
Expand Down
3 changes: 3 additions & 0 deletions pipeline/src/transformers/eventDocument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ export const transformEventDocument = (
id,
tags,
} = document;
const uid = document.uid || undefined;

const documentTimes = times.map(transformTimes);

Expand All @@ -166,10 +167,12 @@ export const transformEventDocument = (

return {
id,
uid,
...(tags.includes('delist') && { isChildScheduledEvent: true }),
display: {
type: 'Event',
id,
uid,
title: asTitle(title),
image,
times: times.map(transformTimes),
Expand Down
1 change: 1 addition & 0 deletions pipeline/src/types/transformed/article.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Contributor, Image } from '.';
export type Article = {
type: 'Article';
id: string;
uid?: string;
title: string;
publicationDate: string;
contributors: Contributor[];
Expand Down
1 change: 1 addition & 0 deletions pipeline/src/types/transformed/eventDocument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Image, Series } from '.';
export type EventDocument = {
type: 'Event';
id: string;
uid?: string;
title: string;
image?: Image;
times: {
Expand Down
2 changes: 2 additions & 0 deletions pipeline/src/types/transformed/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export type {

export type ElasticsearchArticle = {
id: string;
uid?: string;
display: Article;
query: {
linkedIdentifiers: string[];
Expand All @@ -70,6 +71,7 @@ export type ElasticsearchArticle = {

export type ElasticsearchEventDocument = {
id: string;
uid?: string;
isChildScheduledEvent?: boolean;
display: EventDocument;
query: {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions pipeline/test/transformers/__snapshots__/article.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ exports[`article transformer also works for webcomics (document: webcomics/XK9p2
"publicationDate": "2019-04-12T09:00:00+0000",
"title": "Groan",
"type": "Article",
"uid": "groan",
},
"filter": {
"contributorIds": [
Expand Down Expand Up @@ -131,6 +132,7 @@ exports[`article transformer also works for webcomics (document: webcomics/XK9p2
"standfirst": undefined,
"title": "Groan",
},
"uid": "groan",
}
`;

Expand Down Expand Up @@ -233,6 +235,7 @@ exports[`article transformer also works for webcomics (document: webcomics/XUGru
"publicationDate": "2019-08-02T09:00:00+0000",
"title": "Footpath",
"type": "Article",
"uid": "footpath",
},
"filter": {
"contributorIds": [
Expand Down Expand Up @@ -265,6 +268,7 @@ exports[`article transformer also works for webcomics (document: webcomics/XUGru
"standfirst": undefined,
"title": "Footpath",
},
"uid": "footpath",
}
`;

Expand Down Expand Up @@ -363,6 +367,7 @@ exports[`article transformer transforms articles from Prismic to the expected fo
"publicationDate": "2017-08-07T23:00:01+0000",
"title": "Ken’s ten: looking back at ten years of Wellcome Collection",
"type": "Article",
"uid": "ken-s-ten--looking-back-at-ten-years-of-wellcome-collection",
},
"filter": {
"contributorIds": [
Expand Down Expand Up @@ -408,6 +413,7 @@ exports[`article transformer transforms articles from Prismic to the expected fo
"standfirst": "Ken Arnold led the team that established Wellcome Collection in 2007. As Head of Public Programmes for much of the past decade, he’s had a unique view of the exhibitions, live events and activities on offer. Here he shares 10 of his most memorable exhibits and events. ",
"title": "Ken’s ten: looking back at ten years of Wellcome Collection",
},
"uid": "ken-s-ten--looking-back-at-ten-years-of-wellcome-collection",
}
`;

Expand Down Expand Up @@ -494,6 +500,7 @@ exports[`article transformer transforms articles from Prismic to the expected fo
"publicationDate": "2017-10-11T08:30:00+0000",
"title": "The Key to Memory: Follow your nose",
"type": "Article",
"uid": "the-key-to-memory--follow-your-nose",
},
"filter": {
"contributorIds": [],
Expand Down Expand Up @@ -563,6 +570,7 @@ exports[`article transformer transforms articles from Prismic to the expected fo
"standfirst": "For Why Music? The Key to Memory, a partnership with BBC Radio 3, we’re exploring what four objects from our collection can tell us about how we remember. Take a look as Elissavet Ntoulia tells Georgia Mann why a pair of pomanders holds a key to memory.",
"title": "The Key to Memory: Follow your nose",
},
"uid": "the-key-to-memory--follow-your-nose",
}
`;

Expand Down Expand Up @@ -679,6 +687,7 @@ exports[`article transformer transforms articles from Prismic to the expected fo
"publicationDate": "2022-10-18T09:00:00+0000",
"title": "Tracing the roots of our fears and fixations",
"type": "Article",
"uid": "tracing-the-roots-of-our-fears-and-fixations",
},
"filter": {
"contributorIds": [
Expand Down Expand Up @@ -748,6 +757,7 @@ exports[`article transformer transforms articles from Prismic to the expected fo
"standfirst": "Our obsessions are contradictory and multiple: deeply intimate, yet forged by the times we live in. In ‘The Book of Phobias and Manias’, Kate Summerscale offers an A–Z compendium of our fixations, and what they say about us and society. In this extract, she explores how the way we describe our anxieties and compulsions has developed, and the new phobias and manias that are always emerging.",
"title": "Tracing the roots of our fears and fixations",
},
"uid": "tracing-the-roots-of-our-fears-and-fixations",
}
`;

Expand Down Expand Up @@ -850,6 +860,7 @@ exports[`article transformer transforms articles from Prismic to the expected fo
"publicationDate": "2022-01-10T10:59:43+0000",
"title": "The enigma of the medieval folding almanac",
"type": "Article",
"uid": "the-enigma-of-the-medieval-folding-almanac",
},
"filter": {
"contributorIds": [
Expand Down Expand Up @@ -909,5 +920,6 @@ exports[`article transformer transforms articles from Prismic to the expected fo
"standfirst": "In our collections there’s a small, jewel-like folding almanac, which is remarkable not only for its beautiful and intricate construction but also for the detailed information it contains on the medieval connections between astrology and the human body.",
"title": "The enigma of the medieval folding almanac",
},
"uid": "the-enigma-of-the-medieval-folding-almanac",
}
`;
Loading

0 comments on commit be59057

Please sign in to comment.