Skip to content

Commit

Permalink
Black formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
AetherUnbound committed Dec 21, 2020
1 parent 47a8a26 commit 9c75ecf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 32 deletions.
36 changes: 11 additions & 25 deletions src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,25 @@
@app.route("/")
def home():
"""Reroute home URL to license lookup form"""
return redirect(url_for('license_page'))
return redirect(url_for("license_page"))


################################################################################
# Licenses
################################################################################
LICENSE_CONTEXT = {
"title": "Seattle Public Vehicle Lookup",
"entities": [
{
"entity_name_short": "License (wildcard)",
"query_param": "license"
}
],
"entities": [{"entity_name_short": "License (wildcard)", "query_param": "license"}],
"data_source": "https://data.seattle.gov/City-Business/Active-Fleet-Complement/enxu-fgzb",
"lookup_url": "license"
"lookup_url": "license",
}


@app.route("/license")
def license_page():
"""License lookup form render"""
# Check for badge query params and load if it exists.
license = request.args.get('license')
license = request.args.get("license")
html = dataset.license_lookup(license)

# Return the basic lookup form if not
Expand All @@ -50,30 +45,21 @@ def license_page():
NAME_CONTEXT = {
"title": "Seattle Officer Name Lookup",
"entities": [
{
"entity_name_short": "First Name (wildcard)",
"query_param": "first"
},
{
"entity_name_short": "Last Name (wildcard)",
"query_param": "last"
},
{
"entity_name_short": "Badge Number",
"query_param": "badge"
}
{"entity_name_short": "First Name (wildcard)", "query_param": "first"},
{"entity_name_short": "Last Name (wildcard)", "query_param": "last"},
{"entity_name_short": "Badge Number", "query_param": "badge"},
],
"data_source": "https://data.seattle.gov/City-Business/City-of-Seattle-Wage-Data/2khk-5ukd",
"lookup_url": "name"
"lookup_url": "name",
}


@app.route("/name")
def name_page():
"""Officer name lookup form render"""
first_name = request.args.get('first')
last_name = request.args.get('last')
badge = request.args.get('badge')
first_name = request.args.get("first")
last_name = request.args.get("last")
badge = request.args.get("badge")
html = dataset.name_lookup(first_name, last_name, badge)

return render_template("index.html", **NAME_CONTEXT, entity_html=html)
Expand Down
16 changes: 9 additions & 7 deletions src/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@

class RosterRecord(NamedTuple):
serial: int
first: str
first: str
middle: str
last: str
title: str
unit: str
last: str
title: str
unit: str


def _sort_names(records: List[Tuple]) -> Generator[RosterRecord, None, None]:
Expand All @@ -54,8 +54,10 @@ def license_lookup(license: str) -> str:
LICENSE_DATASET, limit=1, where=f"license like '{license.upper()}'"
)
if not results:
html = "<p><b>No vehicle found for this license in public dataset</b>" \
"</p><p>(not all undercover vehicles have available information)</p>"
html = (
"<p><b>No vehicle found for this license in public dataset</b>"
"</p><p>(not all undercover vehicles have available information)</p>"
)
else:
r = results[0]
html = render_template("license.j2", **r)
Expand Down Expand Up @@ -117,7 +119,7 @@ def name_lookup(first_name: str, last_name: str, badge: str) -> str:
queries_list = [
("First", "LIKE", first_name),
("Last", "LIKE", last_name),
("Serial", "=", badge)
("Serial", "=", badge),
]
filter_sql_query, query_tuple = _build_sql_query(queries_list)
sql_query = base_sql_query + filter_sql_query
Expand Down

0 comments on commit 9c75ecf

Please sign in to comment.