Increase security and reformat
This commit is contained in:
@@ -74,7 +74,9 @@ def downsample_points(points: list[dict], density: str = "medium") -> list[dict]
|
||||
if bucket_ms <= 0:
|
||||
passthrough.append(
|
||||
{
|
||||
"x": datetime.fromtimestamp(ts_ms / 1000, tz=timezone.utc).isoformat(),
|
||||
"x": datetime.fromtimestamp(
|
||||
ts_ms / 1000, tz=timezone.utc
|
||||
).isoformat(),
|
||||
"y": row.get("y"),
|
||||
"ts_ms": ts_ms,
|
||||
}
|
||||
@@ -116,12 +118,18 @@ def downsample_points(points: list[dict], density: str = "medium") -> list[dict]
|
||||
if not output:
|
||||
return []
|
||||
# Preserve first/last and reduce to density cap if still too large.
|
||||
cap = int(DENSITY_POINT_CAPS.get(str(density or "").strip().lower(), DENSITY_POINT_CAPS["medium"]))
|
||||
cap = int(
|
||||
DENSITY_POINT_CAPS.get(
|
||||
str(density or "").strip().lower(), DENSITY_POINT_CAPS["medium"]
|
||||
)
|
||||
)
|
||||
compact = _compress_to_target(output, cap)
|
||||
return compact
|
||||
|
||||
|
||||
def compact_snapshot_rows(snapshot_rows: list[dict], now_ts_ms: int, cutoff_ts_ms: int) -> set[int]:
|
||||
def compact_snapshot_rows(
|
||||
snapshot_rows: list[dict], now_ts_ms: int, cutoff_ts_ms: int
|
||||
) -> set[int]:
|
||||
"""
|
||||
Returns IDs to keep using the same age-bucket policy as graph sampling.
|
||||
Old rows below cutoff are dropped; remaining rows keep one representative
|
||||
|
||||
Reference in New Issue
Block a user