diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2021-02-24 16:00:52 -0800 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2021-02-24 16:00:54 -0800 |
commit | 8f7345e510af14fbb156ce7dfb05c6b82a711b8b (patch) | |
tree | 83ee0731111235591e859753b3ed538ba85b4f74 /python/fatcat_web/search.py | |
parent | 7da0d7b90cbe6fdc1d119b35a0a5e861af993210 (diff) | |
download | fatcat-8f7345e510af14fbb156ce7dfb05c6b82a711b8b.tar.gz fatcat-8f7345e510af14fbb156ce7dfb05c6b82a711b8b.zip |
handle no-volumes coverage
Instead of an error (iframe-like), shows a blank "no data" chart.
Diffstat (limited to 'python/fatcat_web/search.py')
-rw-r--r-- | python/fatcat_web/search.py | 11 |
1 files 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'] |