Skip to content

Commit

Permalink
Filter programme contexts
Browse files Browse the repository at this point in the history
  • Loading branch information
gunnarvelle committed Nov 10, 2023
1 parent 6ba65b2 commit 9697495
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/api/taxonomyApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export async function fetchSubjects(
value: metadataFilter?.value,
nodeType: 'SUBJECT',
includeContexts: true,
filterProgrammes: true,
isVisible,
});
const response = await taxonomyFetch(
Expand Down Expand Up @@ -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}`,
Expand All @@ -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}`,
Expand All @@ -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}`,
Expand All @@ -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}`,
Expand All @@ -159,6 +162,7 @@ export async function fetchChildren(
nodeType,
recursive,
includeContexts: true,
filterProgrammes: true,
language: context.language,
});
const response = await taxonomyFetch(
Expand All @@ -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}`,
Expand Down Expand Up @@ -233,6 +238,7 @@ interface NodeQueryParams {
value?: string;
isVisible?: boolean;
includeContexts?: boolean;
filterProgrammes?: boolean;
}

export const queryNodes = async (
Expand Down
4 changes: 3 additions & 1 deletion src/resolvers/resourceResolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ export const Query = {
context: ContextWithLoaders,
): Promise<GQLResource> {
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;
Expand Down

0 comments on commit 9697495

Please sign in to comment.