Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
bchu1 committed Jan 23, 2025
1 parent af1415b commit 9671823
Showing 1 changed file with 29 additions and 20 deletions.
49 changes: 29 additions & 20 deletions frontend/packages/data-portal/app/hooks/useDatasetsFilterData.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,40 @@
import { useTypedLoaderData } from 'remix-typedjson'

import { GetDatasetsV2Query } from 'app/__generated_v2__/graphql'
import {
GetDatasetsV2Query,
GetDepositionByIdV2Query,
} from 'app/__generated_v2__/graphql'
import { isDefined } from 'app/utils/nullish'

export function useDatasetsFilterData() {
const { v2 } = useTypedLoaderData<{
v2: GetDatasetsV2Query
v2: GetDatasetsV2Query | GetDepositionByIdV2Query // TODO: Move this data into props.
}>()

return {
organismNames: v2.distinctOrganismNames.aggregate
?.map((aggregate) => aggregate.groupBy?.organismName)
.filter(isDefined),
cameraManufacturers: v2.distinctCameraManufacturers.aggregate
?.map((aggregate) => aggregate.groupBy?.cameraManufacturer)
.filter(isDefined),
reconstructionMethods: v2.distinctReconstructionMethods.aggregate
?.map((aggregate) => aggregate.groupBy?.reconstructionMethod)
.filter(isDefined),
reconstructionSoftwares: v2.distinctReconstructionSoftwares.aggregate
?.map((aggregate) => aggregate.groupBy?.reconstructionSoftware)
.filter(isDefined),
objectNames: v2.distinctObjectNames.aggregate
?.map((aggregate) => aggregate.groupBy?.objectName)
.filter(isDefined),
objectShapeTypes: v2.distinctShapeTypes.aggregate
?.map((aggregate) => aggregate.groupBy?.shapeType)
.filter(isDefined),
organismNames:
v2.distinctOrganismNames.aggregate
?.map((aggregate) => aggregate.groupBy?.organismName)
.filter(isDefined) ?? [],
cameraManufacturers:
v2.distinctCameraManufacturers.aggregate
?.map((aggregate) => aggregate.groupBy?.cameraManufacturer)
.filter(isDefined) ?? [],
reconstructionMethods:
v2.distinctReconstructionMethods.aggregate
?.map((aggregate) => aggregate.groupBy?.reconstructionMethod)
.filter(isDefined) ?? [],
reconstructionSoftwares:
v2.distinctReconstructionSoftwares.aggregate
?.map((aggregate) => aggregate.groupBy?.reconstructionSoftware)
.filter(isDefined) ?? [],
objectNames:
v2.distinctObjectNames.aggregate
?.map((aggregate) => aggregate.groupBy?.objectName)
.filter(isDefined) ?? [],
objectShapeTypes:
v2.distinctShapeTypes.aggregate
?.map((aggregate) => aggregate.groupBy?.shapeType)
.filter(isDefined) ?? [],
}
}

0 comments on commit 9671823

Please sign in to comment.