Last active
April 27, 2021 01:24
-
-
Save jiobu1/81f529dbac80980dea0973eccaa12637 to your computer and use it in GitHub Desktop.
school summary for each city
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SchoolData(BaseModel): | |
total_schools: int | |
percent_high_performing_schools: float | |
percent_private: float | |
percent_public: float | |
percent_charter: float | |
async def get_school_summary(city: City): | |
"""Retrieve recommended cities for target city | |
Fetch data from DB | |
args: | |
- city: The target city | |
returns: | |
- Dictionary that contains the requested data, which is converted | |
by fastAPI to a json object. | |
""" | |
city = validate_city(city) | |
value = await select_all(city) | |
full_data = SchoolData(city=city, **value) | |
data = {**full_data.dict()} | |
return data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment