Skip to content

Commit

Permalink
Making daily/annual values nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
caparker committed Oct 30, 2024
1 parent 7ea1688 commit 0108664
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions openaq_api/openaq_api/v3/models/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,11 @@ class HourlyData(Measurement):


class DailyData(Measurement):
...
value: float | None = None # Nullable to deal with errors


class AnnualData(Measurement):
...
value: float | None = None # Nullable to deal with errors


# Similar to measurement but without timestamps
Expand Down
8 changes: 4 additions & 4 deletions openaq_api/openaq_api/v3/routers/measurements.py
Original file line number Diff line number Diff line change
Expand Up @@ -1012,8 +1012,8 @@ async def fetch_days(query, db):
SELECT sn.id
, json_build_object(
'label', '1day'
, 'datetime_from', get_datetime_object(h.datetime - '1day'::interval, sn.timezone)
, 'datetime_to', get_datetime_object(h.datetime, sn.timezone)
, 'datetime_from', get_datetime_object(h.datetime, sn.timezone)
, 'datetime_to', get_datetime_object(h.datetime + '1day'::interval, sn.timezone)
, 'interval', '24:00:00'
) as period
, json_build_object(
Expand Down Expand Up @@ -1064,8 +1064,8 @@ async def fetch_years(query, db):
SELECT sn.id
, json_build_object(
'label', '1year'
, 'datetime_from', get_datetime_object(h.datetime - '1year'::interval, sn.timezone)
, 'datetime_to', get_datetime_object(h.datetime, sn.timezone)
, 'datetime_from', get_datetime_object(h.datetime, sn.timezone)
, 'datetime_to', get_datetime_object(h.datetime + '1year'::interval, sn.timezone)
, 'interval', '1 year'
) as period
, json_build_object(
Expand Down

0 comments on commit 0108664

Please sign in to comment.