diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2020-09-17 21:14:38 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2020-09-17 21:14:38 -0700 |
commit | 897fb1921dc0fe9a7506cb7d0e648a17d26f3ee4 (patch) | |
tree | 6657b6904dc9c20e77704876ed904b9258c1b33c /python | |
parent | 2812b3a363ec41eb11a35affb128f66b39d40e6d (diff) | |
download | fatcat-897fb1921dc0fe9a7506cb7d0e648a17d26f3ee4.tar.gz fatcat-897fb1921dc0fe9a7506cb7d0e648a17d26f3ee4.zip |
coverage: handle the case of hits, but none with years
Diffstat (limited to 'python')
-rw-r--r-- | python/fatcat_web/search.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/python/fatcat_web/search.py b/python/fatcat_web/search.py index 7d9ce69f..755b303a 100644 --- a/python/fatcat_web/search.py +++ b/python/fatcat_web/search.py @@ -604,10 +604,11 @@ def get_elastic_preservation_by_year(query) -> List[dict]: buckets = resp.aggregations.year_preservation.buckets year_nums = set([int(h['key']['year']) for h in buckets]) year_dicts = dict() - for num in range(min(year_nums), max(year_nums)+1): - year_dicts[num] = dict(year=num, bright=0, dark=0, shadows_only=0, none=0) - for row in buckets: - year_dicts[int(row['key']['year'])][row['key']['preservation']] = int(row['doc_count']) + if year_nums: + for num in range(min(year_nums), max(year_nums)+1): + year_dicts[num] = dict(year=num, bright=0, dark=0, shadows_only=0, none=0) + for row in buckets: + year_dicts[int(row['key']['year'])][row['key']['preservation']] = int(row['doc_count']) if app.config['FATCAT_MERGE_SHADOW_PRESERVATION']: for k in year_dicts.keys(): year_dicts[k]['none'] += year_dicts[k]['shadows_only'] |