Skip to content

Commit 74e7bdd

Browse files
committed
Fix archived spools showing as Unknown in reports (#58)
Include archived spools when building the spool lookup map for usage reports so they retain their name, color, and material info.
1 parent d0a1fde commit 74e7bdd

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

app/src/app/api/reports/usage/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export async function GET(request: NextRequest) {
129129
const spoolmanConnection = await prisma.spoolmanConnection.findFirst();
130130
if (spoolmanConnection) {
131131
const client = new SpoolmanClient(spoolmanConnection.url);
132-
const spools = await client.getSpools();
132+
const spools = await client.getSpools(true); // Include archived spools for historical reports
133133
spoolLookup = new Map(spools.map(s => [s.id, s]));
134134
}
135135
} catch {

app/src/lib/api/spoolman.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,9 @@ export class SpoolmanClient {
195195
/**
196196
* Get all spools
197197
*/
198-
async getSpools(): Promise<Spool[]> {
199-
return this.fetch('/spool');
198+
async getSpools(includeArchived = false): Promise<Spool[]> {
199+
const params = includeArchived ? '?allow_archived=true' : '';
200+
return this.fetch(`/spool${params}`);
200201
}
201202

202203
/**

0 commit comments

Comments
 (0)