summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2021-02-24 16:00:52 -0800
committerBryan Newbold <bnewbold@robocracy.org>2021-02-24 16:00:54 -0800
commit8f7345e510af14fbb156ce7dfb05c6b82a711b8b (patch)
tree83ee0731111235591e859753b3ed538ba85b4f74
parent7da0d7b90cbe6fdc1d119b35a0a5e861af993210 (diff)
downloadfatcat-8f7345e510af14fbb156ce7dfb05c6b82a711b8b.tar.gz
fatcat-8f7345e510af14fbb156ce7dfb05c6b82a711b8b.zip
handle no-volumes coverage
Instead of an error (iframe-like), shows a blank "no data" chart.
-rw-r--r--python/fatcat_web/search.py11
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']