
- Set up SQLite database configuration and directory structure - Configure Alembic for proper SQLite migrations - Add initial model schemas and API endpoints - Fix OAuth2 authentication - Implement proper code formatting with Ruff
56 lines
2.2 KiB
Python
56 lines
2.2 KiB
Python
from datetime import datetime
|
|
from typing import List, Optional
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class WeatherData(BaseModel):
|
|
"""Schema for current weather data."""
|
|
temperature: float # Temperature in Celsius
|
|
feels_like: float # Feels like temperature in Celsius
|
|
humidity: int = Field(..., ge=0, le=100) # Humidity in percentage
|
|
pressure: int # Atmospheric pressure in hPa
|
|
wind_speed: float # Wind speed in meters/sec
|
|
wind_direction: int = Field(..., ge=0, le=360) # Wind direction in degrees
|
|
weather_condition: str # Main weather condition (e.g., "Rain", "Clear")
|
|
weather_description: str # Detailed weather description
|
|
weather_icon: str # Icon code for the weather condition
|
|
clouds: int = Field(..., ge=0, le=100) # Cloudiness in percentage
|
|
timestamp: datetime # Time of data calculation
|
|
sunrise: datetime # Sunrise time
|
|
sunset: datetime # Sunset time
|
|
|
|
|
|
class ForecastItem(BaseModel):
|
|
"""Schema for a single forecast item."""
|
|
timestamp: datetime # Time of forecasted data
|
|
temperature: float # Temperature in Celsius
|
|
feels_like: float # Feels like temperature in Celsius
|
|
humidity: int = Field(..., ge=0, le=100) # Humidity in percentage
|
|
pressure: int # Atmospheric pressure in hPa
|
|
wind_speed: float # Wind speed in meters/sec
|
|
wind_direction: int = Field(..., ge=0, le=360) # Wind direction in degrees
|
|
weather_condition: str # Main weather condition
|
|
weather_description: str # Detailed weather description
|
|
weather_icon: str # Icon code for the weather condition
|
|
clouds: int = Field(..., ge=0, le=100) # Cloudiness in percentage
|
|
probability_of_precipitation: float = Field(..., ge=0, le=1) # Probability of precipitation
|
|
|
|
|
|
class Forecast(BaseModel):
|
|
"""Schema for weather forecast data."""
|
|
location_name: str
|
|
items: List[ForecastItem]
|
|
|
|
|
|
class CurrentWeather(BaseModel):
|
|
"""Schema for current weather response."""
|
|
location_name: str
|
|
weather: WeatherData
|
|
|
|
|
|
class WeatherQuery(BaseModel):
|
|
"""Schema for querying weather data."""
|
|
latitude: float = Field(..., le=90, ge=-90)
|
|
longitude: float = Field(..., le=180, ge=-180)
|
|
location_name: Optional[str] = None |