Logic and background for Related works queries
PreviousRFC 076: Integrating the catalogue graph into the works pipelineNextRFC 077: Content API: Enriching addressable content types with Works data
Last updated
There have been a few different tickets tackling the desired MVP logic for the Related works component and even more conversations around what we think should be queried. Because of the amount of people involved, we thought it best to document those decisions somewhere. It is likely to change and be improved upon.
This .org helpers file containing the queries
The component gets added to a works page if the work has at least one subject label.
The base of all queries lies with the subject labels. If a work does not have any subject labels, we don't query for the others at all, since their results would be too generic.
The queries are split into three categories:
Subject related
From the same century (date range) with similar subjects
Genres related, with similar subjects
For each query we fetch 4 works, because we want to display 3 and the work being viewed is likely to be returned as a result. We filter it out afterwards.
We query a maximum of three individual subjects, a date range if it can be determined and up to two genres. There can therefore be up of six queries made on each work page.
Up to three queries/tabs. Uses the first three subjects from the response array.
pageSize: 4
includes: [production, contributor] - required for the display data we need for cards
subjects.label: one of the first three subject labels of the work
One query/tab Used for a "Century" tab, e.g. "From 1900s".
Valid:
1999
1284
1683
Not valid:
[1928]
1937?
From 1930 to 1934
1933-1954
If the string is valid, we then use it to get the century range.
pageSize: 4
includes: [production, contributor]
subjects.label: the first three subject labels of the work
production.dates.from: First day of the century
production.dates.to: Last day of the century
Maximum of 2 genres/tabs, but only because we wanted to reduce the amount of total queries. The original request was for up to 3 tabs for genres.
We get the first two genres in the response array:genres?.map(genre => genre.label).slice(0, 2)
So up to two queries are done, by looping through the above's results:
pageSize: 4
includes: [production, contributor]
subjects.label: the first three subject labels of the work
genres.label: The genre label
We have found some related works results that made it clear more work would be required on the logic.
https://wellcomecollection.org/works/a2262ru9 https://wellcomecollection.org/works/a376cmj9
It's strange when one of the subject label is date related, because we then also have the century tab. That can be the same century or a different one, if the work is a modern one about a different century.
https://wellcomecollection.org/works/a22xvp3c
Many works will display the same results for most of their tabs. An answer would be to fetch more works and compare/filter them, but we chose not to do that at this stage.
Last updated