diff --git a/frontend/packages/data-portal/app/apollo.server.ts b/frontend/packages/data-portal/app/apollo.server.ts index efa0e9ead..84ace687c 100644 --- a/frontend/packages/data-portal/app/apollo.server.ts +++ b/frontend/packages/data-portal/app/apollo.server.ts @@ -22,7 +22,7 @@ export const apolloClientV2 = new ApolloClient({ fetchPolicy: 'no-cache', }, }, - cache: new InMemoryCache(), + cache: new InMemoryCache({ addTypename: false }), // TODO(bchu): Re-enable __typename when fixed in BE. link: createHttpLink({ uri: process.env.API_URL_V2 ?? ENVIRONMENT_CONTEXT_DEFAULT_VALUE.API_URL_V2, }), diff --git a/frontend/packages/data-portal/app/components/Run/RunHeader.tsx b/frontend/packages/data-portal/app/components/Run/RunHeader.tsx index a5d1c8ce9..63ab5e655 100644 --- a/frontend/packages/data-portal/app/components/Run/RunHeader.tsx +++ b/frontend/packages/data-portal/app/components/Run/RunHeader.tsx @@ -50,6 +50,7 @@ export function RunHeader() { resolutions, annotationFilesAggregates, tomogramsCount, + alignmentsCount, } = useRunById() const { toggleDrawer } = useMetadataDrawer() const { t } = useI18n() @@ -142,8 +143,9 @@ export function RunHeader() { : 'text-sds-color-primitive-gray-500', }, { - key: t('alignmentFile'), - value: '', // TODO(bchu): Confirm how this should be counted. + key: t('alignment'), + value: + alignmentsCount > 0 ? t('available') : t('notSubmitted'), }, { key: t('tomograms'), diff --git a/frontend/packages/data-portal/app/graphql/getRunByIdDiffer.ts b/frontend/packages/data-portal/app/graphql/getRunByIdDiffer.ts index 2aedf920e..3370602a1 100644 --- a/frontend/packages/data-portal/app/graphql/getRunByIdDiffer.ts +++ b/frontend/packages/data-portal/app/graphql/getRunByIdDiffer.ts @@ -10,7 +10,7 @@ import { Tomogram_Reconstruction_Method_Enum, } from 'app/__generated_v2__/graphql' -/* eslint-disable no-console */ +/* eslint-disable no-console, no-param-reassign */ export function logIfHasDiff( url: string, v1: GetRunByIdQuery, @@ -18,24 +18,25 @@ export function logIfHasDiff( ): void { console.log('Checking for run query diffs') - // eslint-disable-next-line no-param-reassign v2 = structuredClone(v2) + // There are no alignments in V1. + delete v2.alignmentsAggregate.aggregate // Tomogram deposition relations in V1 are incomplete. for (const tomogram of v2.tomograms) { delete tomogram.deposition } + // Frames are not populated in V2 yet. + for (const run of v2.runs) { + delete run.framesAggregate + } const v1Transformed: GetRunByIdV2Query = { runs: v1.runs.map((run) => ({ - __typename: 'Run', id: run.id, name: run.name, tiltseries: { - __typename: 'TiltseriesConnection', edges: run.tiltseries.map((runTiltseries) => ({ - __typename: 'TiltseriesEdge', node: { - __typename: 'Tiltseries', accelerationVoltage: runTiltseries.acceleration_voltage, alignedTiltseriesBinning: runTiltseries.aligned_tiltseries_binning, binningFromFrames: runTiltseries.binning_from_frames, @@ -67,7 +68,6 @@ export function logIfHasDiff( })), }, dataset: { - __typename: 'Dataset', cellComponentName: run.dataset.cell_component_name, cellComponentId: run.dataset.cell_component_id, cellName: run.dataset.cell_name, @@ -95,22 +95,16 @@ export function logIfHasDiff( tissueId: run.dataset.tissue_id, title: run.dataset.title, fundingSources: { - __typename: 'DatasetFundingConnection', edges: run.dataset.funding_sources.map((source) => ({ - __typename: 'DatasetFundingEdge', node: { - __typename: 'DatasetFunding', fundingAgencyName: source.funding_agency_name, grantId: source.grant_id, }, })), }, authors: { - __typename: 'DatasetAuthorConnection', edges: run.dataset.authors.map((author) => ({ - __typename: 'DatasetAuthorEdge', node: { - __typename: 'DatasetAuthor', correspondingAuthorStatus: author.corresponding_author_status, email: author.email, name: author.name, @@ -121,19 +115,13 @@ export function logIfHasDiff( }, }, tomogramVoxelSpacings: { - __typename: 'TomogramVoxelSpacingConnection', edges: run.tomogram_voxel_spacings.map((tomogramVoxelSpacing) => ({ - __typename: 'TomogramVoxelSpacingEdge', node: { - __typename: 'TomogramVoxelSpacing', id: tomogramVoxelSpacing.id, s3Prefix: tomogramVoxelSpacing.s3_prefix!, tomograms: { - __typename: 'TomogramConnection', edges: tomogramVoxelSpacing.tomograms.map((tomogram) => ({ - __typename: 'TomogramEdge', node: { - __typename: 'Tomogram', ctfCorrected: tomogram.ctf_corrected, fiducialAlignmentStatus: tomogram.fiducial_alignment_status as Fiducial_Alignment_Status_Enum, @@ -153,7 +141,6 @@ export function logIfHasDiff( sizeZ: tomogram.size_z, voxelSpacing: tomogram.voxel_spacing, alignment: { - __typename: 'Alignment', affineTransformationMatrix: JSON.stringify( tomogram.affine_transformation_matrix, ).replaceAll(',', ', '), @@ -164,9 +151,20 @@ export function logIfHasDiff( }, })), }, + tiltseriesAggregate: { + aggregate: [ + { + count: run.tiltseries_aggregate.aggregate?.count, + avg: { + tiltSeriesQuality: + run.tiltseries_aggregate.aggregate?.avg?.tilt_series_quality, + }, + }, + ], + }, })), + alignmentsAggregate: {}, tomograms: v1.tomograms.map((tomogram) => ({ - __typename: 'Tomogram', ctfCorrected: tomogram.ctf_corrected, fiducialAlignmentStatus: tomogram.fiducial_alignment_status as Fiducial_Alignment_Status_Enum, @@ -193,17 +191,13 @@ export function logIfHasDiff( tomogramVoxelSpacing: tomogram.tomogram_voxel_spacing != null ? { - __typename: 'TomogramVoxelSpacing', id: tomogram.tomogram_voxel_spacing.id, s3Prefix: tomogram.tomogram_voxel_spacing.s3_prefix!, } : undefined, authors: { - __typename: 'TomogramAuthorConnection', edges: tomogram.authors.map((author) => ({ - __typename: 'TomogramAuthorEdge', node: { - __typename: 'TomogramAuthor', primaryAuthorStatus: author.primary_author_status, correspondingAuthorStatus: author.corresponding_author_status, name: author.name, diff --git a/frontend/packages/data-portal/app/graphql/getRunByIdV2.server.ts b/frontend/packages/data-portal/app/graphql/getRunByIdV2.server.ts index 453cc0672..69fe04c91 100644 --- a/frontend/packages/data-portal/app/graphql/getRunByIdV2.server.ts +++ b/frontend/packages/data-portal/app/graphql/getRunByIdV2.server.ts @@ -151,17 +151,26 @@ const GET_RUN_BY_ID_QUERY_V2 = gql(` } # Header - # tiltseriesAggregate { # TODO(bchu): Uncomment when __typename bug is fixed. - # aggregate { - # count - # avg { - # tiltSeriesQuality - # } - # # sum { - # # tiltseriesFramesCount # TODO(bchu): Uncomment when populated. - # # } - # } - # } + framesAggregate { + aggregate { + count + } + } + tiltseriesAggregate { + aggregate { + count + avg { + tiltSeriesQuality + } + } + } + } + + # Header + alignmentsAggregate(where: {run: {id: {_eq: $id}}}) { + aggregate { + count + } } # Annotations table diff --git a/frontend/packages/data-portal/app/hooks/useRunById.ts b/frontend/packages/data-portal/app/hooks/useRunById.ts index 6483a1f1c..7299e11e2 100644 --- a/frontend/packages/data-portal/app/hooks/useRunById.ts +++ b/frontend/packages/data-portal/app/hooks/useRunById.ts @@ -47,6 +47,8 @@ export function useRunById() { const tomogramsCount = v1.tomograms_aggregate.aggregate?.count ?? 0 + const alignmentsCount = v2.alignmentsAggregate.aggregate?.[0]?.count ?? 0 + const { deposition } = v1 return { @@ -60,6 +62,7 @@ export function useRunById() { resolutions, annotationFilesAggregates, tomogramsCount, + alignmentsCount, deposition, } } diff --git a/frontend/packages/data-portal/e2e/apollo.ts b/frontend/packages/data-portal/e2e/apollo.ts index 348608711..e9b9bcc1f 100644 --- a/frontend/packages/data-portal/e2e/apollo.ts +++ b/frontend/packages/data-portal/e2e/apollo.ts @@ -19,7 +19,7 @@ export function getApolloClient() { export function getApolloClientV2() { return new apollo.ApolloClient({ ssrMode: true, - cache: new apollo.InMemoryCache(), + cache: new apollo.InMemoryCache({ addTypename: false }), // TODO(bchu): Re-enable __typename when fixed in BE. link: apollo.createHttpLink({ uri: process.env.API_URL_V2 ?? ENVIRONMENT_CONTEXT_DEFAULT_VALUE.API_URL_V2,