Minor project page bugfixes

This commit is contained in:
maziggy
2026-01-15 07:47:05 +01:00
parent d95d35c556
commit 1e08c3d5a9
4 changed files with 112 additions and 98 deletions
+21 -9
View File
@@ -49,18 +49,19 @@ async def compute_project_stats(db: AsyncSession, project_id: int, target_count:
)
total_items = total_items_result.scalar() or 0
# Sum completed items (using quantity field)
# Count completed archives (number of print jobs) - includes "archived" as successful
completed_result = await db.execute(
select(func.coalesce(func.sum(PrintArchive.quantity), 0)).where(
PrintArchive.project_id == project_id, PrintArchive.status == "completed"
select(func.count(PrintArchive.id)).where(
PrintArchive.project_id == project_id, PrintArchive.status.in_(["completed", "archived"])
)
)
completed_prints = completed_result.scalar() or 0
# Sum failed items (using quantity field)
# Count failed archives (number of print jobs) - includes all failure states
failed_result = await db.execute(
select(func.coalesce(func.sum(PrintArchive.quantity), 0)).where(
PrintArchive.project_id == project_id, PrintArchive.status == "failed"
select(func.count(PrintArchive.id)).where(
PrintArchive.project_id == project_id,
PrintArchive.status.in_(["failed", "aborted", "cancelled", "stopped"]),
)
)
failed_prints = failed_result.scalar() or 0
@@ -169,15 +170,24 @@ async def list_projects(
)
queue_count = queue_count_result.scalar() or 0
# Get completed count for progress (sum of quantities)
# Count completed archives - includes "archived" as successful
completed_result = await db.execute(
select(func.coalesce(func.sum(PrintArchive.quantity), 0)).where(
select(func.count(PrintArchive.id)).where(
PrintArchive.project_id == project.id,
PrintArchive.status == "completed",
PrintArchive.status.in_(["completed", "archived"]),
)
)
completed_count = int(completed_result.scalar() or 0)
# Count failed archives - includes all failure states
failed_result = await db.execute(
select(func.count(PrintArchive.id)).where(
PrintArchive.project_id == project.id,
PrintArchive.status.in_(["failed", "aborted", "cancelled", "stopped"]),
)
)
failed_count = int(failed_result.scalar() or 0)
progress_percent = None
if project.target_count and project.target_count > 0:
progress_percent = round((completed_count / project.target_count) * 100, 1)
@@ -213,6 +223,8 @@ async def list_projects(
created_at=project.created_at,
archive_count=archive_count,
total_items=total_items,
completed_count=completed_count,
failed_count=failed_count,
queue_count=queue_count,
progress_percent=progress_percent,
archives=archive_previews,
+3 -1
View File
@@ -117,7 +117,9 @@ class ProjectListResponse(BaseModel):
created_at: datetime
# Quick stats
archive_count: int = 0 # Number of print jobs
total_items: int = 0 # Sum of quantities (total items printed)
total_items: int = 0 # Sum of quantities (total items printed, including failed)
completed_count: int = 0 # Sum of quantities for completed prints only
failed_count: int = 0 # Sum of quantities for failed prints
queue_count: int = 0
progress_percent: float | None = None
# Preview of archives (up to 5)
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -23,7 +23,7 @@
<!-- Splash screens for iOS -->
<link rel="apple-touch-startup-image" href="/img/android-chrome-512x512.png" />
<script type="module" crossorigin src="/assets/index-WNO7X-o0.js"></script>
<script type="module" crossorigin src="/assets/index-D7518JU5.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-DAZKHkJ3.css">
</head>
<body>