From 8f7345e510af14fbb156ce7dfb05c6b82a711b8b Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Wed, 24 Feb 2021 16:00:52 -0800 Subject: handle no-volumes coverage Instead of an error (iframe-like), shows a blank "no data" chart. --- python/fatcat_web/search.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/python/fatcat_web/search.py b/python/fatcat_web/search.py index 755b303a..6a419fa8 100644 --- a/python/fatcat_web/search.py +++ b/python/fatcat_web/search.py @@ -738,11 +738,12 @@ def get_elastic_container_preservation_by_volume(container_id: str) -> List[dict buckets = resp.aggregations.volume_preservation.buckets volume_nums = set([int(h['key']['volume']) for h in buckets if h['key']['volume'].isdigit()]) volume_dicts = dict() - for num in range(min(volume_nums), max(volume_nums)+1): - volume_dicts[num] = dict(volume=num, bright=0, dark=0, shadows_only=0, none=0) - for row in buckets: - if row['key']['volume'].isdigit(): - volume_dicts[int(row['key']['volume'])][row['key']['preservation']] = int(row['doc_count']) + if volume_nums: + for num in range(min(volume_nums), max(volume_nums)+1): + volume_dicts[num] = dict(volume=num, bright=0, dark=0, shadows_only=0, none=0) + for row in buckets: + if row['key']['volume'].isdigit(): + volume_dicts[int(row['key']['volume'])][row['key']['preservation']] = int(row['doc_count']) if app.config['FATCAT_MERGE_SHADOW_PRESERVATION']: for k in volume_dicts.keys(): volume_dicts[k]['none'] += volume_dicts[k]['shadows_only'] -- cgit v1.2.3