summaryrefslogtreecommitdiffstats
path: root/python/fatcat_web/search.py
diff options
context:
space:
mode:
authorMartin Czygan <martin@archive.org>2020-09-29 10:19:30 +0000
committerMartin Czygan <martin@archive.org>2020-09-29 10:19:30 +0000
commitd0f4155bc430d193451472b6c22b6a15e00a5785 (patch)
tree279951c3c14a1d5bb196744e939b647dd15ca943 /python/fatcat_web/search.py
parent3112fcd6457e318069830d1af7ae6e9512f52f59 (diff)
parent897fb1921dc0fe9a7506cb7d0e648a17d26f3ee4 (diff)
downloadfatcat-d0f4155bc430d193451472b6c22b6a15e00a5785.tar.gz
fatcat-d0f4155bc430d193451472b6c22b6a15e00a5785.zip
Merge branch 'bnewbold-202009-polish' into 'master'
fatcat.wiki 2020-09 polish See merge request webgroup/fatcat!84
Diffstat (limited to 'python/fatcat_web/search.py')
-rw-r--r--python/fatcat_web/search.py9
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']