fix: bump history limits to 100k so all-time shows full dataset
This commit is contained in:
@@ -21,8 +21,8 @@ class PostgresHistory:
|
|||||||
end: datetime.datetime,
|
end: datetime.datetime,
|
||||||
limit: int = 2000,
|
limit: int = 2000,
|
||||||
) -> List[Dict]:
|
) -> List[Dict]:
|
||||||
if not 1 <= limit <= 10000:
|
if not 1 <= limit <= 100000:
|
||||||
raise ValueError("limit must be between 1 and 10000")
|
raise ValueError("limit must be between 1 and 100000")
|
||||||
if start >= end:
|
if start >= end:
|
||||||
raise ValueError("start must be before end")
|
raise ValueError("start must be before end")
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -452,7 +452,7 @@ async def get_thaiwater_sensors():
|
|||||||
async def get_postgres_history(
|
async def get_postgres_history(
|
||||||
station_code: str,
|
station_code: str,
|
||||||
hours: int = Query(168, ge=1),
|
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."""
|
"""Get historical measurements for a station from PostgreSQL."""
|
||||||
cache_key = f"{station_code}:{hours}:{limit}"
|
cache_key = f"{station_code}:{hours}:{limit}"
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ def test_history_rejects_excessive_limit():
|
|||||||
history = PostgresHistory.__new__(PostgresHistory)
|
history = PostgresHistory.__new__(PostgresHistory)
|
||||||
|
|
||||||
try:
|
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:
|
except ValueError as error:
|
||||||
assert "limit" in str(error)
|
assert "limit" in str(error)
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user