Skip to content

Commit

Permalink
Mock analysis response
Browse files Browse the repository at this point in the history
  • Loading branch information
Agnieszka Figiel committed Dec 5, 2023
1 parent 0ab342c commit abfb2da
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions cloud_functions/analysis/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,19 @@ def index(request):
return get_locations_stats(db)

def get_locations_stats(db: sqlalchemy.engine.base.Engine) -> dict:
with db.connect() as conn:
stmt = sqlalchemy.text(
"SELECT COUNT(*) FROM locations WHERE type=:type"
)
regions_count = conn.execute(stmt, parameters={"type": "region"}).scalar()
countries_count = conn.execute(stmt, parameters={"type": "country"}).scalar()
# just an example of a query
# with db.connect() as conn:
# stmt = sqlalchemy.text(
# "SELECT COUNT(*) FROM locations WHERE type=:type"
# )
# regions_count = conn.execute(stmt, parameters={"type": "region"}).scalar()
# countries_count = conn.execute(stmt, parameters={"type": "country"}).scalar()

# mock response
return {
"regions_count": regions_count,
"countries_count": countries_count
}
"locations_area": [
{"code": "FRA", "protected_area": 2385406},
{"code": "USA", "protected_area": 5000367}
],
"total_area": 73600000,
}

0 comments on commit abfb2da

Please sign in to comment.