summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2020-07-02 19:24:00 -0700
committerBryan Newbold <bnewbold@robocracy.org>2020-07-30 18:17:54 -0700
commitf2a4a69eec8868c76c5d3c466318444ad3e5148c (patch)
tree6b9c708b4ea44a7bbdec6f6e43764086c27e40e8
parent5e98b863c8c5bef2c03e5596172e5f16dc2a9da1 (diff)
downloadfatcat-f2a4a69eec8868c76c5d3c466318444ad3e5148c.tar.gz
fatcat-f2a4a69eec8868c76c5d3c466318444ad3e5148c.zip
graphics: handle empty coverage years
-rw-r--r--python/fatcat_web/graphics.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/python/fatcat_web/graphics.py b/python/fatcat_web/graphics.py
index 56852627..5493d175 100644
--- a/python/fatcat_web/graphics.py
+++ b/python/fatcat_web/graphics.py
@@ -9,13 +9,14 @@ def ia_coverage_histogram(rows):
raw_years = [int(r[0]) for r in rows]
years = dict()
- for y in range(min(raw_years), max(raw_years)+1):
- years[int(y)] = dict(year=int(y), available=0, missing=0)
- for r in rows:
- if r[1]:
- years[int(r[0])]['available'] = r[2]
- else:
- years[int(r[0])]['missing'] = r[2]
+ if raw_years:
+ for y in range(min(raw_years), max(raw_years)+1):
+ years[int(y)] = dict(year=int(y), available=0, missing=0)
+ for r in rows:
+ if r[1]:
+ years[int(r[0])]['available'] = r[2]
+ else:
+ years[int(r[0])]['missing'] = r[2]
years = sorted(years.values(), key=lambda x: x['year'])