From 5cb4d4b453c9edf993c492438707447219abe735 Mon Sep 17 00:00:00 2001 From: Matt Webster Date: Mon, 1 Mar 2021 23:23:40 -0800 Subject: [PATCH] Add created_hour Fixes #976 --- server/api/code/lacity_data_api/routers/reports.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server/api/code/lacity_data_api/routers/reports.py b/server/api/code/lacity_data_api/routers/reports.py index dc2b8f4c7..a62885ddc 100644 --- a/server/api/code/lacity_data_api/routers/reports.py +++ b/server/api/code/lacity_data_api/routers/reports.py @@ -28,6 +28,10 @@ 'DOW', ServiceRequest.created_date ).label('created_dow'), + "created_hour": db.extract( + 'HOUR', + ServiceRequest.created_date + ).label('created_hour'), "created_date": cast( ServiceRequest.created_date, DATE ).label('created_date'), @@ -46,7 +50,7 @@ async def run_report( field: Optional[List[str]] = Query( ["type_name", "created_date"], description="ex. created_date", - regex="""(created_year|created_month|created_dow|created_date|council_name|type_name|agency_name|source_name)""" # noqa + regex="""(created_year|created_month|created_dow|created_hour|created_date|council_name|type_name|agency_name|source_name)""" # noqa ), filter: Optional[List[str]] = Query( [f"created_date>={str(datetime.date.today().year) + '-01-01'}"],