From a56442dc49c726090adb0854f090d9e9c8941e57 Mon Sep 17 00:00:00 2001 From: Madison Swain-Bowden Date: Thu, 10 Feb 2022 20:32:37 -0800 Subject: [PATCH] Fix City of Seattle hourly rate conversion (#78) * Fix City of Seattle hourly rate conversion * Simplify cleaning logic --- src/extras.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/extras.py b/src/extras.py index 6048ea9..f1bdd27 100644 --- a/src/extras.py +++ b/src/extras.py @@ -37,7 +37,13 @@ def _augment_with_salary_cached(last: Optional[str], first: Optional[str]) -> st if not results: return "" s = results[0] - projected = Decimal(s["hourly_rate"]) * 40 * 50 + hourly_rate = s["hourly_rate"] + # City of Seattle wage data formats rate as "$ " for some + # horrible reason, so we clean this data a bit for decimal conversion. + if isinstance(hourly_rate, str): + hourly_rate = hourly_rate.strip("$ ") + s["hourly_rate"] = hourly_rate + projected = Decimal(hourly_rate) * 40 * 50 # Format with commas context = {**s, "projected": f"{projected:,}"} return render_template("extras/seattle-salary.html", **context)