Add 2026 theme build and retrieval timeline

This commit is contained in:
Orion
2026-06-05 12:18:04 +08:00
parent 7a62a79763
commit a8615aca0b
3 changed files with 38 additions and 6 deletions
+22 -6
View File
@@ -643,7 +643,7 @@ class FileService:
is_permanent=is_permanent,
can_download=can_download,
)
timeline = self._build_file_timeline(
timeline = await self._build_file_timeline(
file_code=file_code,
detail=detail,
now=now,
@@ -1205,7 +1205,7 @@ class FileService:
},
}
def _build_file_timeline(
async def _build_file_timeline(
self,
file_code: FileCodes,
detail: dict[str, Any],
@@ -1249,7 +1249,7 @@ class FileService:
"key": "expiration_policy",
"status": "unlimited",
"severity": "success",
"timestamp": None,
"timestamp": file_code.created_at,
}
)
elif file_code.expired_at is not None:
@@ -1271,7 +1271,7 @@ class FileService:
"key": "download_limit",
"status": "exhausted" if exhausted else "active",
"severity": "danger" if exhausted else "info",
"timestamp": None,
"timestamp": file_code.created_at,
"value": remaining_downloads,
}
)
@@ -1281,20 +1281,36 @@ class FileService:
"key": "download_limit",
"status": "unlimited",
"severity": "success",
"timestamp": None,
"timestamp": file_code.created_at,
"value": None,
}
)
download_stats = await TransferStats.filter(
action="download", file_code_id=file_code.id
).order_by("created_at")
timeline.append(
{
"key": "retrieved",
"status": "done" if file_code.used_count > 0 else "pending",
"severity": "success" if file_code.used_count > 0 else "neutral",
"timestamp": None,
"timestamp": (
download_stats[-1].created_at if download_stats else file_code.created_at
),
"value": file_code.used_count,
}
)
for index, stat in enumerate(download_stats, start=1):
timeline.append(
{
"key": "retrieved_event",
"status": "done",
"severity": "success",
"timestamp": stat.created_at,
"value": index,
"detail": stat.ip or "",
}
)
return timeline
def _seconds_between(