diff --git a/src/routes/dashboard/admin/print/+page.server.ts b/src/routes/dashboard/admin/print/+page.server.ts index 3b91488..43b70e2 100644 --- a/src/routes/dashboard/admin/print/+page.server.ts +++ b/src/routes/dashboard/admin/print/+page.server.ts @@ -2,6 +2,7 @@ import { db } from '$lib/server/db/index.js'; import { project, user, devlog } from '$lib/server/db/schema.js'; import { error } from '@sveltejs/kit'; import { eq, and, sql, ne, inArray } from 'drizzle-orm'; +import { alias } from 'drizzle-orm/pg-core'; import type { Actions } from './$types'; import { getCurrentlyPrinting } from './utils.server'; @@ -83,6 +84,8 @@ async function getProjects( projectFilter: number[], userFilter: number[] ) { + const printer = alias(user, 'printer'); + return await db .select({ project: { @@ -91,18 +94,24 @@ async function getProjects( description: project.description, url: project.url, createdAt: project.createdAt, - status: project.status + status: project.status, + claimedAt: project.claimedAt }, user: { id: user.id, name: user.name }, + printer: { + id: printer.id, + name: printer.name + }, timeSpent: sql`COALESCE(SUM(${devlog.timeSpent}), 0)`, devlogCount: sql`COALESCE(COUNT(${devlog.id}), 0)` }) .from(project) .leftJoin(devlog, and(eq(project.id, devlog.projectId), eq(devlog.deleted, false))) .leftJoin(user, eq(user.id, project.userId)) + .leftJoin(printer, eq(printer.id, project.printedBy)) .where( and( eq(project.deleted, false), @@ -118,7 +127,10 @@ async function getProjects( project.url, project.createdAt, project.status, + project.claimedAt, user.id, - user.name + user.name, + printer.id, + printer.name ); } diff --git a/src/routes/dashboard/admin/print/+page.svelte b/src/routes/dashboard/admin/print/+page.svelte index fc8301f..b8d2b8c 100644 --- a/src/routes/dashboard/admin/print/+page.svelte +++ b/src/routes/dashboard/admin/print/+page.svelte @@ -204,6 +204,16 @@

{projectStatuses[project.project.status]}

+ {#if project.project.status === 'printing' && project.printer?.name} +

+ Claimed by {project.printer.name} + {#if project.project.claimedAt} + + {relativeDate(project.project.claimedAt)} + + {/if} +

+ {/if} {/each}