Skip to content

Commit ea152fc

Browse files
fix: deposition annotations count (#1679)
fix annotations count
1 parent 97588e8 commit ea152fc

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

frontend/packages/data-portal/app/components/Deposition/DatasetsTable.tsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -240,14 +240,10 @@ export function DatasetsTable() {
240240

241241
columnHelper.accessor(
242242
(dataset) =>
243-
dataset.runs.edges
244-
.flatMap(
245-
(run) =>
246-
run.node.annotationsAggregate?.aggregate?.map(
247-
(aggregate) => aggregate.count ?? 0,
248-
) ?? [],
249-
)
250-
.reduce((prevCount, nextCount) => prevCount + nextCount, 0),
243+
deposition.annotationsAggregate?.aggregate?.find(
244+
(agg) => agg.groupBy?.run?.dataset?.id === dataset.id,
245+
)?.count ?? 0,
246+
251247
{
252248
id: 'annotations',
253249

@@ -328,6 +324,7 @@ export function DatasetsTable() {
328324
}
329325
}, [
330326
datasetSort,
327+
deposition.annotationsAggregate?.aggregate,
331328
getDatasetUrl,
332329
isLoadingDebounced,
333330
searchParams,

frontend/packages/data-portal/app/components/Deposition/DepositionOverview.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ export function DepositionOverview() {
7171
{t('annotations')}:
7272
</span>
7373
{(
74-
deposition.annotationsAggregate?.aggregate?.[0]?.count ?? 0
74+
deposition.annotationsAggregate?.aggregate?.reduce(
75+
(total, { count }) => total + (count ?? 0),
76+
0,
77+
) ?? 0
7578
).toLocaleString()}
7679
</p>
7780
</div>

frontend/packages/data-portal/app/graphql/getDepositionByIdV2.server.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ const GET_DEPOSITION_BY_ID = gql(`
5151
annotationsAggregate {
5252
aggregate {
5353
count
54+
55+
groupBy {
56+
run {
57+
dataset {
58+
id
59+
}
60+
}
61+
}
5462
}
5563
}
5664
annotationMethodCounts: annotationsAggregate {

0 commit comments

Comments
 (0)