Compare commits
1 commit
ba82cf557e
...
98290f0b05
Author | SHA1 | Date | |
---|---|---|---|
98290f0b05 |
1 changed files with 0 additions and 5 deletions
5
main.py
5
main.py
|
@ -13,7 +13,6 @@ import httpx
|
||||||
|
|
||||||
logger = logging.getLogger("uvicorn.error")
|
logger = logging.getLogger("uvicorn.error")
|
||||||
|
|
||||||
# Constants
|
|
||||||
EASTERN_TZ = zoneinfo.ZoneInfo("America/New_York")
|
EASTERN_TZ = zoneinfo.ZoneInfo("America/New_York")
|
||||||
CACHE_TTL_SECONDS = 900 # 15 minutes
|
CACHE_TTL_SECONDS = 900 # 15 minutes
|
||||||
CACHE_MAX_SIZE = 100
|
CACHE_MAX_SIZE = 100
|
||||||
|
@ -113,10 +112,8 @@ class FinalReport(TypedDict):
|
||||||
today: DailyData
|
today: DailyData
|
||||||
tomorrow: DailyData
|
tomorrow: DailyData
|
||||||
|
|
||||||
# Initialize FastAPI app
|
|
||||||
app = FastAPI(title="TRMNL Weather & Pollen Report")
|
app = FastAPI(title="TRMNL Weather & Pollen Report")
|
||||||
|
|
||||||
# Cache instances
|
|
||||||
weather_cache: TTLCache = TTLCache(maxsize=CACHE_MAX_SIZE, ttl=CACHE_TTL_SECONDS)
|
weather_cache: TTLCache = TTLCache(maxsize=CACHE_MAX_SIZE, ttl=CACHE_TTL_SECONDS)
|
||||||
pollen_cache: TTLCache = TTLCache(maxsize=CACHE_MAX_SIZE, ttl=CACHE_TTL_SECONDS)
|
pollen_cache: TTLCache = TTLCache(maxsize=CACHE_MAX_SIZE, ttl=CACHE_TTL_SECONDS)
|
||||||
|
|
||||||
|
@ -412,7 +409,6 @@ class DataAggregator:
|
||||||
p["period"]: p for p in weather_data[0]["periods"]
|
p["period"]: p for p in weather_data[0]["periods"]
|
||||||
}
|
}
|
||||||
|
|
||||||
# Add current weather data as a separate structure
|
|
||||||
current_weather_info = CurrentWeatherData({
|
current_weather_info = CurrentWeatherData({
|
||||||
"temp": 0,
|
"temp": 0,
|
||||||
"feels_like": 0,
|
"feels_like": 0,
|
||||||
|
@ -464,7 +460,6 @@ async def get_weather_pollen_report(token: str) -> FinalReport:
|
||||||
today_date = DateTimeFormatter.format_date(now)
|
today_date = DateTimeFormatter.format_date(now)
|
||||||
tomorrow_date = DateTimeFormatter.format_date(now + timedelta(days=1))
|
tomorrow_date = DateTimeFormatter.format_date(now + timedelta(days=1))
|
||||||
|
|
||||||
# Build response
|
|
||||||
result: FinalReport = FinalReport({
|
result: FinalReport = FinalReport({
|
||||||
"fetched_at": DateTimeFormatter.format_datetime(now),
|
"fetched_at": DateTimeFormatter.format_datetime(now),
|
||||||
"current": current_weather_info,
|
"current": current_weather_info,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue