diff options
Diffstat (limited to 'app.py')
-rw-r--r-- | app.py | 25 |
1 files changed, 24 insertions, 1 deletions
@@ -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", |