aboutsummaryrefslogtreecommitdiffstats
path: root/app.py
diff options
context:
space:
mode:
authorjwansek <eddie.atten.ea29@gmail.com>2023-05-16 00:05:27 +0100
committerjwansek <eddie.atten.ea29@gmail.com>2023-05-16 00:05:27 +0100
commit0faf95d56815d310290d3533d81d888deb7731f0 (patch)
treeef9fd281f8b85aab569944eb712235aa321ba768 /app.py
parent469de094098c5cf149b9aeab9c2a7d23aa22c11d (diff)
downloadUKGenderPayGap-0faf95d56815d310290d3533d81d888deb7731f0.tar.gz
UKGenderPayGap-0faf95d56815d310290d3533d81d888deb7731f0.zip
Added heatmap
Diffstat (limited to 'app.py')
-rw-r--r--app.py25
1 files changed, 24 insertions, 1 deletions
diff --git a/app.py b/app.py
index 4f354f7..d5d6ef1 100644
--- a/app.py
+++ b/app.py
@@ -86,6 +86,20 @@ def api_get_sic_section_pay():
return flask.jsonify(db.get_pay_by_sic_section(pay_type, year))
+@app.route("/api/heatmap")
+def api_get_heatmap_data():
+ # pay_type = flask.request.args.get("Pay Type")
+ year = flask.request.args.get("year")
+ # print("year: '%s'" % year)
+ # if pay_type is None or pay_type.lower() not in {'hourly', 'bonuses'}:
+ # return flask.abort(400, "The key `pay type` must be equal to 'hourly' or 'bonuses'")
+ with database.PayGapDatabase(host = host) as db:
+ if year is not None:
+ if year not in db.get_years():
+ return flask.abort(400, "Unrecognised year '%s'. The year option must be in %s" % (year, ", ".join(db.get_years())))
+
+ return flask.jsonify(db.get_heatmap_data("hourly", year))
+
@app.route("/api/getyears")
def api_get_year_options():
with database.PayGapDatabase(host = host) as db:
@@ -107,17 +121,25 @@ def search():
def get_chart_elem(url):
for i in get_charts()["index"]:
- print(i["url"], url)
+ # print(i["url"], url)
# if i["url"] == url:
# return i
if url.startswith(i["url"]):
return i
+def get_chart_elem_strict(url):
+ for i in get_charts()["index"]:
+ print(urllib.parse.urlsplit(i["url"]).path, urllib.parse.urlsplit(url).path)
+ if urllib.parse.urlsplit(i["url"]).path == urllib.parse.urlsplit(url).path:
+ return i
+
@app.route("/plot/<name>")
def serve_large_plot(name):
with database.PayGapDatabase(host = host) as db:
# print(flask.request.full_path)
elem = get_chart_elem(flask.request.full_path)
+ # if elem is None:
+ # elem = get_chart_elem_strict(flask.request.full_path)
filters = elem["filters"]
for k, v in filters.items():
if v == "<SICType>":
@@ -132,6 +154,7 @@ def serve_large_plot(name):
elem["url"] = flask.request.full_path
# print("elem", elem)
current_filters = dict(flask.request.args)
+ print("filters", filters)
print("current_filters", current_filters)
return flask.render_template(
"plot.html.j2",