Skip to content

Commit 5a98bd5

Browse files
committed
Fix: AnVIL summary is lacking file size totals (#7201, PR #7239)
2 parents 0a3dce4 + 527ff3d commit 5a98bd5

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

src/azul/plugins/metadata/anvil/service/aggregation.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ class AnvilSummaryAggregationStage(AnvilAggregationStage):
2828
def prepare_request(self, request: Search) -> Search:
2929
request = super().prepare_request(request)
3030
request = request.extra(size=0)
31+
if self.entity_type == 'files':
32+
request.aggs.metric('totalFileSize',
33+
'sum',
34+
field='contents.files.size_')
3135
return request
3236

3337
def process_response(self, response: MutableJSON) -> MutableJSON:

src/azul/plugins/metadata/anvil/service/response.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ def aggs_by_authority(self) -> Mapping[str, Sequence[str]]:
5252
'diagnoses.phenotype'
5353
],
5454
'files': [
55-
'files.file_format'
55+
'files.file_format',
56+
'totalFileSize'
5657
]
5758
}
5859

@@ -80,6 +81,7 @@ def bucket_count(field, bucket_key):
8081
'donorSpecies': bucket_count('donors.organism_type', 'species'),
8182
'fileCount': doc_count('files.file_format'),
8283
'fileFormats': bucket_count('files.file_format', 'format'),
84+
'totalFileSize': response['totalFileSize']['value'],
8385
}
8486

8587

test/service/test_response_anvil.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2443,7 +2443,8 @@ def test_summary(self):
24432443
'count': 1,
24442444
'format': '.vcf.gz'
24452445
}
2446-
]
2446+
],
2447+
'totalFileSize': 3519867231.0
24472448
}
24482449
url = str(self.base_url.set(path='/index/summary'))
24492450
self._assertResponse(url, expected_response)

0 commit comments

Comments
 (0)