Skip to content

Instantly share code, notes, and snippets.

@jiobu1
Last active April 27, 2021 01:24
Show Gist options
  • Save jiobu1/81f529dbac80980dea0973eccaa12637 to your computer and use it in GitHub Desktop.
Save jiobu1/81f529dbac80980dea0973eccaa12637 to your computer and use it in GitHub Desktop.
school summary for each city
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