Skip to content

Commit

Permalink
feat: Add deposition to V2 run query (#1424)
Browse files Browse the repository at this point in the history
* rebase

* Fix mierge

* remove defualt

* fix test
  • Loading branch information
bchu1 authored Dec 23, 2024
1 parent 9b823e1 commit 2632ac0
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions frontend/packages/data-portal/app/graphql/getRunByIdDiffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,15 @@ export function logIfHasDiff(
})),
},
})),
depositions:
v1.deposition != null
? [
{
id: v1.deposition.id,
title: v1.deposition.title,
},
]
: [],
}

const diffObject = diff(v1Transformed, v2)
Expand Down
30 changes: 24 additions & 6 deletions frontend/packages/data-portal/app/graphql/getRunByIdV2.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -334,6 +335,13 @@ const GET_RUN_BY_ID_QUERY_V2 = gql(`
}
}
}
# Deposition banner
# Returns empty array if $depositionId not defined
depositions(where: { id: { _eq: $depositionId }}) {
id
title
}
}
`)

Expand Down Expand Up @@ -414,12 +422,21 @@ function getAnnotationShapesFilter(
return where
}

export async function getRunByIdV2(
client: ApolloClient<NormalizedCacheObject>,
id: number,
annotationsPage: number,
params: URLSearchParams = new URLSearchParams(),
): Promise<ApolloQueryResult<GetRunByIdV2Query>> {
export interface GetRunByIdV2Params {
client: ApolloClient<NormalizedCacheObject>
id: number
annotationsPage: number
params: URLSearchParams
depositionId?: number
}

export async function getRunByIdV2({
client,
id,
annotationsPage,
params,
depositionId,
}: GetRunByIdV2Params): Promise<ApolloQueryResult<GetRunByIdV2Query>> {
return client.query({
query: GET_RUN_BY_ID_QUERY_V2,
variables: {
Expand All @@ -430,6 +447,7 @@ export async function getRunByIdV2(
id,
getFilterState(params),
),
depositionId,
},
})
}
12 changes: 9 additions & 3 deletions frontend/packages/data-portal/app/routes/runs.$id.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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({
client: apolloClientV2,
id,
annotationsPage,
params: url.searchParams,
depositionId: Number.isNaN(depositionId) ? undefined : depositionId,
}),
])

if (responseV1.runs.length === 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,12 @@ export async function getAnnotationTestData(
export async function getTomogramTestData(
client: ApolloClient<NormalizedCacheObject>,
) {
const { data } = await getRunByIdV2(client, +E2E_CONFIG.runId, 1)
const { data } = await getRunByIdV2({
client,
id: +E2E_CONFIG.runId,
annotationsPage: 1,
params: new URLSearchParams(),
})

const tomogram = data.tomograms[0]
const { dataset } = data.runs[0]
Expand Down

0 comments on commit 2632ac0

Please sign in to comment.