diff --git a/src/postgres_history.py b/src/postgres_history.py index 70d96c8..1bae301 100644 --- a/src/postgres_history.py +++ b/src/postgres_history.py @@ -21,8 +21,8 @@ class PostgresHistory: end: datetime.datetime, limit: int = 2000, ) -> List[Dict]: - if not 1 <= limit <= 10000: - raise ValueError("limit must be between 1 and 10000") + if not 1 <= limit <= 100000: + raise ValueError("limit must be between 1 and 100000") if start >= end: raise ValueError("start must be before end") diff --git a/src/web_api.py b/src/web_api.py index 2e85791..f7764a0 100644 --- a/src/web_api.py +++ b/src/web_api.py @@ -452,7 +452,7 @@ async def get_thaiwater_sensors(): async def get_postgres_history( station_code: str, hours: int = Query(168, ge=1), - limit: int = Query(2000, ge=1, le=10000), + limit: int = Query(50000, ge=1, le=100000), ): """Get historical measurements for a station from PostgreSQL.""" cache_key = f"{station_code}:{hours}:{limit}" diff --git a/tests/test_postgres_history.py b/tests/test_postgres_history.py index 56543ec..50979b8 100644 --- a/tests/test_postgres_history.py +++ b/tests/test_postgres_history.py @@ -42,7 +42,7 @@ def test_history_rejects_excessive_limit(): history = PostgresHistory.__new__(PostgresHistory) try: - history.station_history("P.1", datetime.datetime.now(), datetime.datetime.now(), 10001) + history.station_history("P.1", datetime.datetime.now(), datetime.datetime.now(), 100001) except ValueError as error: assert "limit" in str(error) else: