From 3fbed35dbf72f574c8e2d84d2104bb58caa82aa2 Mon Sep 17 00:00:00 2001 From: Darren Boss Date: Thu, 23 Nov 2023 16:19:34 -0800 Subject: [PATCH] Missing change --- api/app/db/crud/auto_spatial_advisory.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/api/app/db/crud/auto_spatial_advisory.py b/api/app/db/crud/auto_spatial_advisory.py index a3baeab58..91ca7a033 100644 --- a/api/app/db/crud/auto_spatial_advisory.py +++ b/api/app/db/crud/auto_spatial_advisory.py @@ -240,9 +240,27 @@ async def save_high_hfi_area(session: AsyncSession, high_hfi_area: HighHfiArea): session.add(high_hfi_area) +async def store_advisory_fuel_stats(session: AsyncSession, fuel_type_areas: dict, threshold: int, run_parameters_id: int, advisory_shape_id: int): + """ + Creates AdvisoryFuelStats objects and save them in the wps database. + + :param : A dictionary keyed by fuel type code with value representing an area in square meters. + :param threshold: The current threshold being processed, 1 = 4k-10k, 2 = > 10k. + :param run_parameters_id: The RunParameter object id associated with the run_type, for_date and run_datetime of interest. + :param advisory_shape_id: The id of advisory shape (eg. fire zone unit) the fuel type area has been calcualted for. + """ + advisory_fuel_stats = [] + for key in fuel_type_areas: + advisory_fuel_stats.append( + AdvisoryFuelStats(advisory_shape_id=advisory_shape_id, threshold=threshold, run_parameters=run_parameters_id, fuel_type=key, area=fuel_type_areas[key]) + ) + await save_advisory_fuel_stats(session, advisory_fuel_stats) + + async def save_advisory_fuel_stats(session: AsyncSession, advisory_fuel_stats: List[AdvisoryFuelStats]): session.add_all(advisory_fuel_stats) + async def calculate_high_hfi_areas(session: AsyncSession, run_type: RunType, run_datetime: datetime, for_date: date) -> List[Row]: """