|
1 | 1 | import datetime as dt |
2 | | -from collections.abc import Iterator |
3 | 2 |
|
4 | 3 | from sqlalchemy import MetaData, insert |
5 | 4 | from sqlalchemy.orm import Session |
@@ -65,20 +64,17 @@ def load_stations(stations: list[dict[str, str]], *, session: Session) -> None: |
65 | 64 | session.commit() |
66 | 65 |
|
67 | 66 |
|
68 | | -def generate_event_objects(raw_events: Iterator[dict[str, str]]) -> list[Event]: |
69 | | - return [ |
70 | | - Event( |
71 | | - station_id=event["station_id"], |
72 | | - time_start=dt.datetime.fromisoformat(event["start"]), |
73 | | - time_end=dt.datetime.fromisoformat(event["end"]), |
74 | | - snow_on_ground=_snow_on_ground_status(event["sog"]), |
75 | | - rain_hours=int(event["RA"]), |
76 | | - freezing_rain_hours=int(event["FZRA"]), |
77 | | - solid_precipitation_hours=int(event["SOLID"]), |
78 | | - unknown_precipitation_hours=int(event["UP"]), |
79 | | - ) |
80 | | - for event in raw_events |
81 | | - ] |
| 67 | +def generate_event_object(raw_event: dict[str, str]) -> Event: |
| 68 | + return Event( |
| 69 | + station_id=raw_event["station_id"], |
| 70 | + time_start=dt.datetime.fromisoformat(raw_event["start"]), |
| 71 | + time_end=dt.datetime.fromisoformat(raw_event["end"]), |
| 72 | + snow_on_ground=_snow_on_ground_status(raw_event["sog"]), |
| 73 | + rain_hours=int(raw_event["RA"]), |
| 74 | + freezing_rain_hours=int(raw_event["FZRA"]), |
| 75 | + solid_precipitation_hours=int(raw_event["SOLID"]), |
| 76 | + unknown_precipitation_hours=int(raw_event["UP"]), |
| 77 | + ) |
82 | 78 |
|
83 | 79 |
|
84 | 80 | def load_events(events: list[Event], *, session: Session) -> None: |
|
0 commit comments