From ac678ff0d8e6b85d61a3b4848d0bcfe2eabfebaa Mon Sep 17 00:00:00 2001 From: Bryan Chu Date: Fri, 24 Jan 2025 11:03:23 -0800 Subject: [PATCH] --- .../data-portal/app/hooks/useDepositionById.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/frontend/packages/data-portal/app/hooks/useDepositionById.ts b/frontend/packages/data-portal/app/hooks/useDepositionById.ts index 0bcd63169..a3cf572de 100644 --- a/frontend/packages/data-portal/app/hooks/useDepositionById.ts +++ b/frontend/packages/data-portal/app/hooks/useDepositionById.ts @@ -2,17 +2,28 @@ import { useMemo } from 'react' import { useTypedLoaderData } from 'remix-typedjson' import { GetDepositionByIdQuery } from 'app/__generated__/graphql' +import { GetDepositionByIdV2Query } from 'app/__generated_v2__/graphql' +import { isDefined } from 'app/utils/nullish' export type Deposition = NonNullable export type Dataset = GetDepositionByIdQuery['datasets'][number] export function useDepositionById() { - const { v1, annotationMethodCounts } = useTypedLoaderData<{ + const { v1, v2 } = useTypedLoaderData<{ v1: GetDepositionByIdQuery - annotationMethodCounts: Map + v2: GetDepositionByIdV2Query }>() + const annotationMethodCounts = new Map( + v2.depositions[0].annotationMethodCounts?.aggregate + ?.map((aggregate) => [ + aggregate.groupBy?.annotationMethod, + aggregate.count ?? 0, + ]) + .filter((entry): entry is [string, number] => isDefined(entry[0])) ?? [], + ) + const objectNames = useMemo( () => Array.from(