From 5f93f45c216e71c693c05357e7821450c1836090 Mon Sep 17 00:00:00 2001 From: Conor Brady Date: Thu, 9 Nov 2023 16:11:06 -0800 Subject: [PATCH] Fix check lookup --- .../auto_spatial_advisory/process_elevation_hfi.py | 1 - .../process_fuel_type_area.py | 14 ++------------ .../auto_spatial_advisory/process_high_hfi_area.py | 10 +++------- 3 files changed, 5 insertions(+), 20 deletions(-) diff --git a/api/app/auto_spatial_advisory/process_elevation_hfi.py b/api/app/auto_spatial_advisory/process_elevation_hfi.py index 26e9cb309..732d4c22d 100644 --- a/api/app/auto_spatial_advisory/process_elevation_hfi.py +++ b/api/app/auto_spatial_advisory/process_elevation_hfi.py @@ -18,7 +18,6 @@ async def process_hfi_elevation(run_type: RunType, run_date: date, run_datetime: :param for_date: The date of the hfi to process. (when is the hfi for?) """ - # TODO: check for already processed HFI elevation data based on run parameters logger.info('Processing HFI elevation %s for run date: %s, for date: %s', run_type, run_date, for_date) perf_start = perf_counter() diff --git a/api/app/auto_spatial_advisory/process_fuel_type_area.py b/api/app/auto_spatial_advisory/process_fuel_type_area.py index 2f09a3bfb..74018fe76 100644 --- a/api/app/auto_spatial_advisory/process_fuel_type_area.py +++ b/api/app/auto_spatial_advisory/process_fuel_type_area.py @@ -4,30 +4,20 @@ import logging from datetime import date, datetime from time import perf_counter -from sqlalchemy.ext.asyncio import AsyncSession from sqlalchemy.future import select from app.auto_spatial_advisory.run_type import RunType from app.db.database import get_async_write_session_scope -from app.db.models.auto_spatial_advisory import AdvisoryFuelStats, HighHfiArea +from app.db.models.auto_spatial_advisory import AdvisoryFuelStats from app.db.crud.auto_spatial_advisory import (get_all_hfi_thresholds, get_all_sfms_fuel_types, get_high_hfi_fuel_types, get_run_parameters_id, - save_advisory_fuel_stats, - save_high_hfi_area) + save_advisory_fuel_stats) logger = logging.getLogger(__name__) -async def write_high_hfi_area(session: AsyncSession, row: any, run_parameters_id: int): - high_hfi_area = HighHfiArea(advisory_shape_id=row.shape_id, - run_parameters=run_parameters_id, - area=row.area, - threshold=row.threshold) - await save_high_hfi_area(session, high_hfi_area) - - async def process_fuel_type_area(run_type: RunType, run_datetime: datetime, for_date: date): """ Create new fuel type analysis records for the given date. diff --git a/api/app/auto_spatial_advisory/process_high_hfi_area.py b/api/app/auto_spatial_advisory/process_high_hfi_area.py index 1f9341ae6..c8b59b62a 100644 --- a/api/app/auto_spatial_advisory/process_high_hfi_area.py +++ b/api/app/auto_spatial_advisory/process_high_hfi_area.py @@ -5,12 +5,11 @@ import logging from datetime import date, datetime from sqlalchemy.future import select -from sqlalchemy import cast, String from time import perf_counter from sqlalchemy.ext.asyncio import AsyncSession from app.auto_spatial_advisory.run_type import RunType from app.db.database import get_async_write_session_scope -from app.db.models.auto_spatial_advisory import ClassifiedHfi, HighHfiArea +from app.db.models.auto_spatial_advisory import HighHfiArea from app.db.crud.auto_spatial_advisory import get_run_parameters_id, calculate_high_hfi_areas, save_high_hfi_area @@ -38,11 +37,8 @@ async def process_high_hfi_area(run_type: RunType, run_datetime: datetime, for_d async with get_async_write_session_scope() as session: run_parameters_id = await get_run_parameters_id(session, run_type, run_datetime, for_date) - stmt = select(ClassifiedHfi)\ - .where( - cast(ClassifiedHfi.run_type, String) == run_type.value, - ClassifiedHfi.for_date == for_date, - ClassifiedHfi.run_datetime == run_datetime) + stmt = select(HighHfiArea)\ + .where(HighHfiArea.run_parameters == run_parameters_id) exists = (await session.execute(stmt)).scalars().first() is not None