From 0801197ff49629da9ed27735571642d1c516b8ec Mon Sep 17 00:00:00 2001 From: Russ Biggs Date: Tue, 3 Oct 2023 11:08:32 -0700 Subject: [PATCH] add redis client to app state (#299) --- openaq_api/openaq_api/main.py | 1 + openaq_api/openaq_api/routers/auth.py | 1 - openaq_api/openaq_api/routers/measurements.py | 2 -- openaq_api/openaq_api/v3/routers/countries.py | 1 - 4 files changed, 1 insertion(+), 4 deletions(-) diff --git a/openaq_api/openaq_api/main.py b/openaq_api/openaq_api/main.py index 25d22d7..47317c4 100644 --- a/openaq_api/openaq_api/main.py +++ b/openaq_api/openaq_api/main.py @@ -209,6 +209,7 @@ async def startup_event(): app.state.counter += 1 else: app.state.counter = 0 + app.state.redis_client = redis_client @app.on_event("shutdown") diff --git a/openaq_api/openaq_api/routers/auth.py b/openaq_api/openaq_api/routers/auth.py index 4a1ff3e..1cf5943 100644 --- a/openaq_api/openaq_api/routers/auth.py +++ b/openaq_api/openaq_api/routers/auth.py @@ -142,7 +142,6 @@ async def check_email(request: Request): @router.get("/verify/{verification_code}") async def verify(request: Request, verification_code: str, db: DB = Depends()): - print(f"\n\n\nAPPP: { getattr(request.app.state, 'redis_client')}\n\n") query = """ SELECT users.users_id, users.is_active, users.expires_on, entities.full_name, users.email_address diff --git a/openaq_api/openaq_api/routers/measurements.py b/openaq_api/openaq_api/routers/measurements.py index 49e2d6f..aeee00d 100644 --- a/openaq_api/openaq_api/routers/measurements.py +++ b/openaq_api/openaq_api/routers/measurements.py @@ -32,8 +32,6 @@ def meas_csv(rows, includefields): - print("ROWS\n\n") - print(rows) output = io.StringIO() writer = csv.writer(output) header = [ diff --git a/openaq_api/openaq_api/v3/routers/countries.py b/openaq_api/openaq_api/v3/routers/countries.py index e071e35..e96d913 100644 --- a/openaq_api/openaq_api/v3/routers/countries.py +++ b/openaq_api/openaq_api/v3/routers/countries.py @@ -107,6 +107,5 @@ async def fetch_countries(query, db): {query_builder.where()} {query_builder.pagination()} """ - print(sql) response = await db.fetchPage(sql, query_builder.params()) return response