mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-19 07:33:18 +02:00
feat(projects): per-file print progress and complete-sets tracking (#1897)
Projects made of many distinct files that each need N prints (e.g. 13
plates x 10 sets = 130 prints) only had aggregate progress. Finding out
"how many times have I printed plate_7?" meant reading the Activity
Timeline line by line, unusable at 130 events.
Projects now take an optional Copies per File target. Every printable
file in the project's linked folders shows an X / N badge with a mini
progress bar (gray not started, amber in progress, green done), and the
progress card gains a Complete Sets bar - the minimum per-file count,
i.e. how many finished assemblies can be shipped right now. Without the
target, printable files show a plain printed-count badge.
Counting matches the aggregate project stats: completed runs only,
served by a new /projects/{id}/file-progress endpoint. Runs attribute
to a file via a new library_file_id stamp on queue-dispatched archives,
falling back to content hash and then filename for historical rows.
Also fixed: files queued from a project-linked File Manager folder now
inherit that project, so their prints count toward project statistics -
previously only prints started from the project page were attributed.
Test-harness fix along the way: the test suite's get_db override never
committed, unlike production get_db, so endpoints relying on the
request-scoped commit silently lost their writes in tests. The override
now mirrors production commit/rollback semantics.
This commit is contained in:
@@ -911,6 +911,7 @@ export interface Project {
|
||||
status: string; // active, completed, archived
|
||||
target_count: number | null; // Target number of plates/print jobs
|
||||
target_parts_count: number | null; // Target number of parts/objects
|
||||
target_sets: number | null; // Copies-per-file target (#1897)
|
||||
notes: string | null;
|
||||
attachments: ProjectAttachment[] | null;
|
||||
tags: string | null;
|
||||
@@ -936,6 +937,12 @@ export interface ProjectAttachment {
|
||||
uploaded_at: string;
|
||||
}
|
||||
|
||||
// Completed-run count for one library file inside a project (#1897)
|
||||
export interface ProjectFileProgress {
|
||||
file_id: number;
|
||||
completed_count: number;
|
||||
}
|
||||
|
||||
export interface ArchivePreview {
|
||||
id: number;
|
||||
print_name: string | null;
|
||||
@@ -953,6 +960,7 @@ export interface ProjectListItem {
|
||||
status: string;
|
||||
target_count: number | null; // Target number of plates/print jobs
|
||||
target_parts_count: number | null; // Target number of parts/objects
|
||||
target_sets: number | null; // #1897 — the shared edit dialog seeds itself from this
|
||||
budget: number | null;
|
||||
tags: string | null; // #2536 — the shared edit dialog seeds itself from this
|
||||
due_date: string | null; // #2536
|
||||
@@ -975,6 +983,7 @@ export interface ProjectCreate {
|
||||
color?: string;
|
||||
target_count?: number;
|
||||
target_parts_count?: number;
|
||||
target_sets?: number;
|
||||
notes?: string;
|
||||
tags?: string;
|
||||
due_date?: string;
|
||||
@@ -991,6 +1000,7 @@ export interface ProjectUpdate {
|
||||
status?: string;
|
||||
target_count?: number;
|
||||
target_parts_count?: number;
|
||||
target_sets?: number | null; // #1897 — explicit null clears the copies-per-file target
|
||||
notes?: string;
|
||||
tags?: string | null; // #2536 — explicit null clears the tags
|
||||
due_date?: string | null; // #2536 — explicit null clears the due date
|
||||
@@ -1062,6 +1072,7 @@ export interface ProjectExport {
|
||||
status: string;
|
||||
target_count: number | null;
|
||||
target_parts_count: number | null;
|
||||
target_sets: number | null; // #1897
|
||||
notes: string | null;
|
||||
tags: string | null;
|
||||
due_date: string | null;
|
||||
@@ -1078,6 +1089,7 @@ export interface ProjectImport {
|
||||
status?: string;
|
||||
target_count?: number;
|
||||
target_parts_count?: number;
|
||||
target_sets?: number; // #1897
|
||||
notes?: string;
|
||||
tags?: string;
|
||||
due_date?: string;
|
||||
@@ -5947,6 +5959,9 @@ export const api = {
|
||||
request<{ message: string }>(`/projects/${id}`, { method: 'DELETE' }),
|
||||
getProjectArchives: (id: number, limit = 100, offset = 0) =>
|
||||
request<Archive[]>(`/projects/${id}/archives?limit=${limit}&offset=${offset}`),
|
||||
// Completed-run counts per library file (#1897); files with 0 runs are omitted
|
||||
getProjectFileProgress: (id: number) =>
|
||||
request<ProjectFileProgress[]>(`/projects/${id}/file-progress`),
|
||||
addArchivesToProject: (projectId: number, archiveIds: number[]) =>
|
||||
request<{ message: string }>(`/projects/${projectId}/add-archives`, {
|
||||
method: 'POST',
|
||||
|
||||
Reference in New Issue
Block a user