fix(web): align trend ranges, next runs and preview task records
This commit is contained in:
1 parent
19572171b8
commit
257fbe009b
7 files changed
+139
-10
No files matched your search
@@ -593,14 +593,15 @@ class DashboardQueries:
|
||||
items.sort(key=lambda item: item["aid"])
|
||||
items.sort(key=sort_key, reverse=True)
|
||||
total = len(items)
|
||||
growth_available = any(
|
||||
item.get("growth", {}).get("available") for item in items
|
||||
)
|
||||
if not export:
|
||||
start = (page - 1) * page_size
|
||||
items = items[start:start + page_size]
|
||||
available = True
|
||||
reason = None
|
||||
if sort in {"growth", "growth_rate"} and not any(
|
||||
item.get("growth", {}).get("available") for item in items
|
||||
):
|
||||
if sort in {"growth", "growth_rate"} and not growth_available:
|
||||
available = False
|
||||
reason = "需要至少两天的快照才能计算增长"
|
||||
return {
|
||||
@@ -678,7 +679,12 @@ class DashboardQueries:
|
||||
"points": [],
|
||||
"available": False,
|
||||
}
|
||||
start = _date_minus(latest, days - 1) if days is not None else str(points[0]["stat_date"])
|
||||
requested_start = (
|
||||
_date_minus(latest, days - 1) if days is not None
|
||||
else str(points[0]["stat_date"])
|
||||
)
|
||||
first_point = str(points[0]["stat_date"])
|
||||
start = max(requested_start, first_point)
|
||||
dates = _date_range(start, latest)
|
||||
by_date = {str(point["stat_date"]): point for point in points}
|
||||
series: dict[str, list[int | None]] = {}
|
||||
@@ -923,7 +929,8 @@ class DashboardQueries:
|
||||
"days": days,
|
||||
}
|
||||
latest = max(str(row["stat_date"]) for row in rows if int(row["ok"]) == 1) if any(int(row["ok"]) == 1 for row in rows) else str(rows[-1]["stat_date"])
|
||||
start = _date_minus(latest, days - 1)
|
||||
first_date = str(rows[0]["stat_date"])
|
||||
start = max(_date_minus(latest, days - 1), first_date)
|
||||
dates = _date_range(start, latest)
|
||||
by_date = {str(row["stat_date"]): row for row in rows}
|
||||
series = []
|
||||
@@ -1034,13 +1041,17 @@ class DashboardQueries:
|
||||
"folder_sync": int(now + cfg.schedule.folder_sync_minutes * 60),
|
||||
"snapshot": int(next_daily_run(now, cfg.schedule.snapshot_at)),
|
||||
}
|
||||
for name, key in (("discover", "discover"), ("folder_sync", "folder_sync")):
|
||||
for name, key, interval_minutes in (
|
||||
("discover", "discovery", cfg.schedule.discover_minutes),
|
||||
("folder_sync", "folder_sync", cfg.schedule.folder_sync_minutes),
|
||||
):
|
||||
record = tasks.get(key)
|
||||
if isinstance(record, dict) and record.get("finished_at"):
|
||||
next_runs[name] = int(record["finished_at"]) + (
|
||||
cfg.schedule.discover_minutes if name == "discover"
|
||||
else cfg.schedule.folder_sync_minutes
|
||||
) * 60
|
||||
interval = int(interval_minutes) * 60
|
||||
candidate = int(record["finished_at"]) + interval
|
||||
while candidate <= now:
|
||||
candidate += interval
|
||||
next_runs[name] = candidate
|
||||
errors = [
|
||||
{"task": name, **record}
|
||||
for name, record in tasks.items()
|
||||
|
||||
Reference in new issue
Block a user