Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Stop using V1 annotation method counts query in deposition page, switch to main deposition V2 query #1517

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions frontend/packages/data-portal/app/hooks/useDepositionById.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<GetDepositionByIdQuery['deposition']>

export type Dataset = GetDepositionByIdQuery['datasets'][number]

export function useDepositionById() {
const { v1, annotationMethodCounts } = useTypedLoaderData<{
const { v1, v2 } = useTypedLoaderData<{
v1: GetDepositionByIdQuery
annotationMethodCounts: Map<string, number>
v2: GetDepositionByIdV2Query
}>()

const annotationMethodCounts = new Map<string, number>(
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(
Expand Down
Loading