Skip to content

Commit

Permalink
Fix check lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
conbrad committed Nov 10, 2023
1 parent ab06c05 commit 5f93f45
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 20 deletions.
1 change: 0 additions & 1 deletion api/app/auto_spatial_advisory/process_elevation_hfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
14 changes: 2 additions & 12 deletions api/app/auto_spatial_advisory/process_fuel_type_area.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 3 additions & 7 deletions api/app/auto_spatial_advisory/process_high_hfi_area.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 5f93f45

Please sign in to comment.