From fab143431a9ce60aab6f41c3786b28207756b60d Mon Sep 17 00:00:00 2001 From: Bryan Chu Date: Mon, 23 Dec 2024 10:19:10 -0800 Subject: [PATCH] rebase --- .../app/graphql/getDatasetByIdV2.server.ts | 1 + .../data-portal/app/graphql/getRunByIdDiffer.ts | 9 +++++++++ .../data-portal/app/graphql/getRunByIdV2.server.ts | 10 ++++++++++ .../packages/data-portal/app/routes/runs.$id.tsx | 12 +++++++++--- 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/frontend/packages/data-portal/app/graphql/getDatasetByIdV2.server.ts b/frontend/packages/data-portal/app/graphql/getDatasetByIdV2.server.ts index 3ab12bc82..733b3c6a7 100644 --- a/frontend/packages/data-portal/app/graphql/getDatasetByIdV2.server.ts +++ b/frontend/packages/data-portal/app/graphql/getDatasetByIdV2.server.ts @@ -202,6 +202,7 @@ const GET_DATASET_BY_ID_QUERY_V2 = gql(` } # Deposition banner + # Returns empty array if $depositionId not defined depositions(where: { id: { _eq: $depositionId }}) { id title diff --git a/frontend/packages/data-portal/app/graphql/getRunByIdDiffer.ts b/frontend/packages/data-portal/app/graphql/getRunByIdDiffer.ts index 8a2114017..e414a2ba3 100644 --- a/frontend/packages/data-portal/app/graphql/getRunByIdDiffer.ts +++ b/frontend/packages/data-portal/app/graphql/getRunByIdDiffer.ts @@ -304,6 +304,15 @@ export function logIfHasDiff( })), }, })), + depositions: + v1.deposition != null + ? [ + { + id: v1.deposition.id, + title: v1.deposition.title, + }, + ] + : [], } const diffObject = diff(v1Transformed, v2) diff --git a/frontend/packages/data-portal/app/graphql/getRunByIdV2.server.ts b/frontend/packages/data-portal/app/graphql/getRunByIdV2.server.ts index ff4a14225..c36d65165 100644 --- a/frontend/packages/data-portal/app/graphql/getRunByIdV2.server.ts +++ b/frontend/packages/data-portal/app/graphql/getRunByIdV2.server.ts @@ -20,6 +20,7 @@ const GET_RUN_BY_ID_QUERY_V2 = gql(` $limit: Int $annotationShapesOffset: Int $annotationShapesFilter: AnnotationShapeWhereClause + $depositionId: Int ) { runs(where: { id: { _eq: $id } }) { id @@ -272,6 +273,13 @@ const GET_RUN_BY_ID_QUERY_V2 = gql(` title } } + + # Deposition banner + # Returns empty array if $depositionId not defined + depositions(where: { id: { _eq: $depositionId }}) { + id + title + } } # Tomograms table + download selector @@ -419,6 +427,7 @@ export async function getRunByIdV2( id: number, annotationsPage: number, params: URLSearchParams = new URLSearchParams(), + depositionId?: number, ): Promise> { return client.query({ query: GET_RUN_BY_ID_QUERY_V2, @@ -430,6 +439,7 @@ export async function getRunByIdV2( id, getFilterState(params), ), + depositionId, }, }) } diff --git a/frontend/packages/data-portal/app/routes/runs.$id.tsx b/frontend/packages/data-portal/app/routes/runs.$id.tsx index 25638e7d5..480ee127a 100644 --- a/frontend/packages/data-portal/app/routes/runs.$id.tsx +++ b/frontend/packages/data-portal/app/routes/runs.$id.tsx @@ -47,17 +47,23 @@ export async function loader({ request, params }: LoaderFunctionArgs) { const annotationsPage = +( url.searchParams.get(QueryParams.AnnotationsPage) ?? '1' ) - const depositionId = +(url.searchParams.get(QueryParams.DepositionId) ?? '-1') + const depositionId = Number(url.searchParams.get(QueryParams.DepositionId)) const [{ data: responseV1 }, { data: responseV2 }] = await Promise.all([ getRunById({ id, annotationsPage, - depositionId, + depositionId: Number.isNaN(depositionId) ? undefined : depositionId, client: apolloClient, params: url.searchParams, }), - getRunByIdV2(apolloClientV2, id, annotationsPage, url.searchParams), + getRunByIdV2( + apolloClientV2, + id, + annotationsPage, + url.searchParams, + Number.isNaN(depositionId) ? undefined : depositionId, + ), ]) if (responseV1.runs.length === 0) {