-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create and display pmtiles for snow coverage (#3444)
Co-authored-by: Conor Brady <con.brad@gmail.com>
- Loading branch information
Showing
20 changed files
with
381 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
""" Routers for Snow related data | ||
""" | ||
|
||
import logging | ||
from datetime import date, datetime | ||
from fastapi import APIRouter, Depends | ||
from app.auth import authentication_required, audit | ||
from app.db.crud.snow import get_most_recent_processed_snow_by_date | ||
from app.db.database import get_async_read_session_scope | ||
from app.schemas.snow import ProcessedSnowModel, ProcessedSnowResponse | ||
from app.utils.time import vancouver_tz | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
router = APIRouter( | ||
prefix="/snow", | ||
dependencies=[Depends(authentication_required), Depends(audit)], | ||
) | ||
|
||
|
||
@router.get('/most-recent-by-date/{for_date}', response_model=ProcessedSnowResponse | None) | ||
async def get_most_recent_by_date(for_date: date, _=Depends(authentication_required)): | ||
""" Returns the most recent processed snow record before or equal to the provided date. """ | ||
logger.info('/snow/most-recent-by-date/') | ||
tz_aware_datetime = vancouver_tz.localize(datetime.combine(for_date, datetime.min.time())) | ||
async with get_async_read_session_scope() as session: | ||
result = await get_most_recent_processed_snow_by_date(session, tz_aware_datetime) | ||
if result is not None: | ||
processed_snow = result[0] | ||
return ProcessedSnowResponse(processed_snow=ProcessedSnowModel(for_date=processed_snow.for_date, processed_date=processed_snow.processed_date, snow_source=processed_snow.snow_source)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
""" This module contains pydantic models related to snow data. """ | ||
|
||
from datetime import datetime | ||
from pydantic import BaseModel | ||
from app.db.models.snow import SnowSourceEnum | ||
|
||
class ProcessedSnowModel(BaseModel): | ||
""" The content of a processed snow object""" | ||
for_date: datetime | ||
processed_date: datetime | ||
snow_source: SnowSourceEnum | ||
|
||
class ProcessedSnowResponse(BaseModel): | ||
""" A processed snow response """ | ||
processed_snow: ProcessedSnowModel | ||
|
Oops, something went wrong.