From 9697495fa77c9abfb23c08dbddfc0f1744a02081 Mon Sep 17 00:00:00 2001 From: Gunnar Velle Date: Fri, 10 Nov 2023 14:56:19 +0100 Subject: [PATCH] Filter programme contexts --- src/api/taxonomyApi.ts | 8 +++++++- src/resolvers/resourceResolvers.ts | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/api/taxonomyApi.ts b/src/api/taxonomyApi.ts index 7c38027c..94feb130 100644 --- a/src/api/taxonomyApi.ts +++ b/src/api/taxonomyApi.ts @@ -58,6 +58,7 @@ export async function fetchSubjects( value: metadataFilter?.value, nodeType: 'SUBJECT', includeContexts: true, + filterProgrammes: true, isVisible, }); const response = await taxonomyFetch( @@ -88,6 +89,7 @@ export async function fetchSubjectTopics( nodeType: 'TOPIC', language: context.language, includeContexts: true, + filterProgrammes: true, }); const response = await taxonomyFetch( `/${context.taxonomyUrl}/v1/nodes/${subjectId}/nodes?${query}`, @@ -105,6 +107,7 @@ export async function fetchTopics( nodeType: 'TOPIC', language: context.language, includeContexts: true, + filterProgrammes: true, }); const response = await taxonomyFetch( `/${context.taxonomyUrl}/v1/nodes?${query}`, @@ -121,6 +124,7 @@ export async function fetchNodeByContentUri( contentURI: contentUri, language: context.language, includeContexts: true, + filterProgrammes: true, }); const response = await taxonomyFetch( `/${context.taxonomyUrl}/v1/nodes?${query}`, @@ -137,7 +141,6 @@ export async function fetchNode( const { id } = params; const query = qs.stringify({ language: context.language, - includeContexts: true, }); const response = await taxonomyFetch( `/${context.taxonomyUrl}/v1/nodes/${id}?${query}`, @@ -159,6 +162,7 @@ export async function fetchChildren( nodeType, recursive, includeContexts: true, + filterProgrammes: true, language: context.language, }); const response = await taxonomyFetch( @@ -181,6 +185,7 @@ export async function fetchNodeResources( language: context.language, relevance: relevance, includeContexts: true, + filterProgrammes: true, }); const response = await taxonomyFetch( `/${context.taxonomyUrl}/v1/nodes/${id}/resources?${query}`, @@ -233,6 +238,7 @@ interface NodeQueryParams { value?: string; isVisible?: boolean; includeContexts?: boolean; + filterProgrammes?: boolean; } export const queryNodes = async ( diff --git a/src/resolvers/resourceResolvers.ts b/src/resolvers/resourceResolvers.ts index c73ed5a2..9ee95a08 100644 --- a/src/resolvers/resourceResolvers.ts +++ b/src/resolvers/resourceResolvers.ts @@ -71,7 +71,9 @@ export const Query = { context: ContextWithLoaders, ): Promise { const resource = await fetchNode({ id }, context); - const visibleCtx = resource.contexts.filter(c => c.isVisible); + const visibleCtx = resource.contexts + .filter(c => c.isVisible) + .filter(c => !c.rootId.startsWith('urn:programme')); const subjectCtx = subjectId ? visibleCtx.filter(c => c.rootId === subjectId) : visibleCtx;