diff --git a/openaq_api/openaq_api/v3/routers/auth.py b/openaq_api/openaq_api/v3/routers/auth.py index 763fa2b..0de6b6b 100644 --- a/openaq_api/openaq_api/v3/routers/auth.py +++ b/openaq_api/openaq_api/v3/routers/auth.py @@ -236,7 +236,7 @@ async def get_register( user_token = await db.get_user_token(body.users_id) if not user_token: return HTTPException(401) - redis_client = getattr(request.app.state, "redis_client") + redis_client = getattr(request.app, "redis") if redis_client: await redis_client.sadd("keys", user_token) return {"message": "success"} diff --git a/openaq_api/openaq_api/v3/routers/locations.py b/openaq_api/openaq_api/v3/routers/locations.py index f00dc99..cc0a2e7 100644 --- a/openaq_api/openaq_api/v3/routers/locations.py +++ b/openaq_api/openaq_api/v3/routers/locations.py @@ -98,7 +98,6 @@ async def location_get( request: Request, db: DB = Depends(), ): - print("FOO", request.app.state.redis_client) response = await fetch_locations(locations, db) return response diff --git a/openaq_api/openaq_api/v3/routers/measurements.py b/openaq_api/openaq_api/v3/routers/measurements.py index d203edf..fc686f5 100644 --- a/openaq_api/openaq_api/v3/routers/measurements.py +++ b/openaq_api/openaq_api/v3/routers/measurements.py @@ -808,8 +808,8 @@ async def fetch_hours_trends(aggregate_to, query, db): , m.measurands_id , m.measurand , m.units - , as_timestamptz(:{datetime_field_name}_from, tz.tzid) as datetime_from - , as_timestamptz(:{datetime_field_name}_to, tz.tzid) as datetime_to + , as_timestamptz(:{datetime_field_name}_from::timestamp, tz.tzid) as datetime_from + , as_timestamptz(:{datetime_field_name}_to::timestamp, tz.tzid) as datetime_to FROM sensors s , sensor_systems sy , sensor_nodes sn @@ -906,6 +906,7 @@ async def fetch_hours_trends(aggregate_to, query, db): ORDER BY e.factor """ + return await db.fetchPage(sql, params) diff --git a/openaq_api/tests/test_sensor_measurements.py b/openaq_api/tests/test_sensor_measurements.py index dc7c42a..aefa5b6 100644 --- a/openaq_api/tests/test_sensor_measurements.py +++ b/openaq_api/tests/test_sensor_measurements.py @@ -95,6 +95,7 @@ def test_aggregated_moy_good(self, client): data = json.loads(response.content).get('results', []) assert len(data) == 12 + row = data[0] # hours are time ending assert row['coverage']['datetimeFrom']['local'] == '2022-01-02T00:00:00-10:00' diff --git a/openaq_api/tests/test_sensors_latest.py b/openaq_api/tests/test_sensors_latest.py index 3cf1b4e..15f3475 100644 --- a/openaq_api/tests/test_sensors_latest.py +++ b/openaq_api/tests/test_sensors_latest.py @@ -53,7 +53,7 @@ def test_date_filter(self, client): response = client.get(f"/v3/parameters/{measurands_id}/latest?datetime_min=2024-08-27") assert response.status_code == 200 data = json.loads(response.content).get('results', []) - assert len(data) == 10 + assert len(data) == 1 def test_timestamp_filter(self, client): response = client.get(f"/v3/parameters/{measurands_id}/latest?datetime_min=2024-08-27 19:00:00")