Skip to content

Commit

Permalink
Merge pull request #112 from Vizzuality/infrastructure/mock_function_…
Browse files Browse the repository at this point in the history
…response

Mock analysis response
  • Loading branch information
Agnieszka Figiel authored Dec 6, 2023
2 parents 0ab342c + abfb2da commit 843289b
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 843289b

Please sign in to comment.