Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
feat: add images to recent and active tabs in MES
Brad Barbinc252337f4deb
diff --git a/apps/mes/app/components/EndShift.tsx b/apps/mes/app/components/EndShift.tsxindex 7f0295fbd7..1f3f729d81 100644--- a/apps/mes/app/components/EndShift.tsx+++ b/apps/mes/app/components/EndShift.tsx@@ -67,11 +67,8 @@ export function EndShift() {return (<>- <SidebarMenuButton- className="text-sidebar-foreground/70"- onClick={openModal}- >- <LuCircleStop className="text-sidebar-foreground/70" />+ <SidebarMenuButton onClick={openModal}>+ <LuCircleStop /><span>End Shift</span></SidebarMenuButton>{confirmModal.isOpen && (diff --git a/apps/mes/app/components/OperationsList.tsx b/apps/mes/app/components/OperationsList.tsxindex d3123e59fd..867039e00d 100644--- a/apps/mes/app/components/OperationsList.tsx+++ b/apps/mes/app/components/OperationsList.tsx@@ -1,6 +1,8 @@import {+ Badge,Card,CardContent,+ CardFooter,CardHeader,cn,HStack,@@ -10,13 +12,21 @@ import {} from "@carbon/react";import {convertDateStringToIsoString,+ formatDate,formatDurationMilliseconds,formatRelativeTime,} from "@carbon/utils";import { Link } from "@remix-run/react";-import { LuClipboardCheck, LuTimer } from "react-icons/lu";+import { cva } from "class-variance-authority";+import {+ LuCalendarDays,+ LuClipboardCheck,+ LuHardHat,+ LuTimer,+} from "react-icons/lu";+import EmployeeAvatar from "~/components/EmployeeAvatar";import type { Operation, OperationSettings } from "~/services/types";-import { path } from "~/utils/path";+import { getPrivateUrl, path } from "~/utils/path";import { DeadlineIcon, OperationStatusIcon } from "./Icons";type OperationsListProps = {@@ -29,9 +39,10 @@ const settings = {showDescription: true,showDueDate: true,showDuration: true,- showEmployee: false,+ showEmployee: true,showProgress: false,showStatus: true,+ showThumbnail: true,}; // TODO: load dynamicallyexport function OperationsList({ operations }: OperationsListProps) {@@ -48,6 +59,26 @@ type OperationCardProps = {operation: Operation;} & OperationSettings;+const cardVariants = cva(+ "bg-card hover:bg-muted/30 dark:border-none dark:shadow-[inset_0_0.5px_0_rgb(255_255_255_/_0.08),_inset_0_0_1px_rgb(255_255_255_/_0.24),_0_0_0_0.5px_rgb(0,0,0,1),0px_0px_4px_rgba(0,_0,_0,_0.08)]",+ {+ variants: {+ status: {+ "In Progress": "border-emerald-600/30",+ Ready: "",+ Done: "",+ Paused: "",+ Canceled: "border-red-500/30",+ Waiting: "",+ Todo: "border-border",+ },+ },+ defaultVariants: {+ status: "Todo",+ },+ }+);+function OperationCard({operation,showCustomer,@@ -57,6 +88,7 @@ function OperationCard({showEmployee,showProgress,showStatus,+ showThumbnail,}: OperationCardProps) {const isOverdue =operation.jobDeadlineType !== "No Deadline" && operation.jobDueDate@@ -64,27 +96,55 @@ function OperationCard({: false;return (- <Link to={path.to.operation(operation.id)}>- <Card className="cursor-pointer shadow">- <CardHeader className={cn("max-w-full p-3 border-b relative")}>- <div className="flex w-full max-w-full justify-between">- <div className="flex flex-col space-y-0">+ <Card+ className={cn(+ "shadow-sm dark:shadow-sm py-0 h-full flex flex-col",+ cardVariants({+ status: operation.operationStatus,+ })+ )}+ >+ <Link+ to={path.to.operation(operation.id)}+ className="flex flex-col flex-1"+ >+ <CardHeader className="-mx-4 relative border-b py-3 px-4 rounded-t-lg">+ <div className="flex w-full max-w-full justify-between items-start gap-0">+ <div className="flex flex-col space-y-0 min-w-0">{operation.itemReadableId && (<span className="text-xs text-muted-foreground line-clamp-1">{operation.itemReadableId}</span>)}- <span className="mr-auto font-semibold line-clamp-1">- {operation.jobReadableId}+ <span className="mr-auto font-semibold line-clamp-2 leading-tight">+ {operation.itemDescription}</span></div></div></CardHeader>- <CardContent className="p-3 space-y-2 text-left whitespace-pre-wrap text-sm">+ <CardContent className="pt-3 px-1 gap-2 text-left whitespace-pre-wrap text-sm flex-grow">+ {showThumbnail && operation.thumbnailPath && (+ <div className="flex justify-center">+ <img+ src={getPrivateUrl(operation.thumbnailPath)}+ alt={operation.jobReadableId}+ className="w-full h-auto rounded-lg"+ />+ </div>+ )}+ <HStack className="justify-start space-x-2">+ <LuHardHat className="text-muted-foreground" />+ <span className="text-sm line-clamp-1">+ {operation.jobReadableId}+ </span>+ </HStack>+{showDescription && operation.description && (<HStack className="justify-start space-x-2"><LuClipboardCheck className="text-muted-foreground" />- <span className="text-sm">{operation.description}</span>+ <span className="text-sm line-clamp-1">+ {operation.description}+ </span></HStack>)}{showStatus && operation.operationStatus && (@@ -102,33 +162,62 @@ function OperationCard({</HStack>)}{showDueDate && operation.jobDeadlineType && (- <HStack className="justify-start space-x-2">- <DeadlineIcon- deadlineType={operation.jobDeadlineType}- overdue={isOverdue}- />- <Tooltip>- <TooltipTrigger>- <span- className={cn("text-sm", isOverdue ? "text-red-500" : "")}- >- {["ASAP", "No Deadline"].includes(operation.jobDeadlineType)- ? operation.jobDeadlineType- : operation.jobDueDate- ? `Due ${formatRelativeTime(- convertDateStringToIsoString(operation.jobDueDate)- )}`- : "–"}+ <>+ <HStack className="justify-start space-x-2">+ <DeadlineIcon+ deadlineType={operation.jobDeadlineType}+ overdue={isOverdue}+ />+ <Tooltip>+ <TooltipTrigger>+ <span+ className={cn("text-sm", isOverdue ? "text-red-500" : "")}+ >+ {["ASAP", "No Deadline"].includes(+ operation.jobDeadlineType+ )+ ? operation.jobDeadlineType+ : operation.jobDueDate+ ? `Due ${formatRelativeTime(+ convertDateStringToIsoString(operation.jobDueDate)+ )}`+ : "–"}+ </span>+ </TooltipTrigger>+ <TooltipContent side="right">+ {operation.jobDeadlineType}+ </TooltipContent>+ </Tooltip>+ </HStack>+ {operation.jobDueDate && (+ <HStack className="justify-start space-x-2">+ <LuCalendarDays />+ <span className="text-sm">+ {formatDate(operation.jobDueDate)}</span>- </TooltipTrigger>- <TooltipContent side="right">- {operation.jobDeadlineType}- </TooltipContent>- </Tooltip>- </HStack>+ </HStack>+ )}+ </>)}</CardContent>- </Card>- </Link>+ {(operation.assignee ||+ (operation.tags && operation.tags.length > 0)) && (+ <CardFooter className="bg-accent/50 -mx-4 border-t px-4 py-2 items-center justify-start space-2 rounded-b-lg text-xs flex-wrap mt-auto">+ {operation.assignee && (+ <EmployeeAvatar size="xs" employeeId={operation.assignee} />+ )}+ {operation.tags?.map((tag) => (+ <Badge+ key={tag}+ variant="secondary"+ className="border dark:border-none dark:shadow-button-base"+ >+ {tag}+ </Badge>+ ))}+ </CardFooter>+ )}+ </Link>+ </Card>);}diff --git a/apps/mes/app/routes/x+/active.tsx b/apps/mes/app/routes/x+/active.tsxindex 8753966e49..d8d7a8180b 100644--- a/apps/mes/app/routes/x+/active.tsx+++ b/apps/mes/app/routes/x+/active.tsx@@ -84,7 +84,7 @@ export default function ActiveRoute() {</div></div>{filteredOperations.length > 0 ? (- <div className="grid grid-cols-[repeat(auto-fill,minmax(min(100%,420px),1fr))] p-4 gap-4">+ <div className="grid grid-cols-[repeat(auto-fill,minmax(min(100%,330px),1fr))] p-4 gap-4"><OperationsList key="active" operations={filteredOperations} /></div>) : searchTerm ? (diff --git a/apps/mes/app/routes/x+/recent.tsx b/apps/mes/app/routes/x+/recent.tsxindex d6cf279fbb..c6474eda65 100644--- a/apps/mes/app/routes/x+/recent.tsx+++ b/apps/mes/app/routes/x+/recent.tsx@@ -83,7 +83,7 @@ export default function ActiveRoute() {</div></div>{filteredOperations.length > 0 ? (- <div className="grid grid-cols-[repeat(auto-fill,minmax(min(100%,420px),1fr))] p-4 gap-4">+ <div className="grid grid-cols-[repeat(auto-fill,minmax(min(100%,330px),1fr))] p-4 gap-4"><OperationsList key="active" operations={filteredOperations} /></div>) : searchTerm ? (diff --git a/apps/mes/app/services/types.ts b/apps/mes/app/services/types.tsindex 088d5362fb..78f2e9d4df 100644--- a/apps/mes/app/services/types.ts+++ b/apps/mes/app/services/types.ts@@ -7,10 +7,11 @@ import type {getLocationsByCompany,getProductionEventsForJobOperation,getProductionQuantitiesForJobOperation,+ getRecentJobOperationsByEmployee,} from "./operations.service";export type BaseOperation = NonNullable<- Awaited<ReturnType<typeof getJobOperationsByWorkCenter>>["data"]+ Awaited<ReturnType<typeof getRecentJobOperationsByEmployee>>["data"]>[number];export type BaseOperationWithDetails = NonNullable<@@ -47,6 +48,7 @@ export type OperationSettings = {showEmployee: boolean;showProgress: boolean;showStatus: boolean;+ showThumbnail: boolean;};export type ProductionEvent = NonNullable<diff --git a/packages/database/src/types.ts b/packages/database/src/types.tsindex a866755545..354fd40a3e 100644--- a/packages/database/src/types.ts+++ b/packages/database/src/types.ts@@ -32412,12 +32412,20 @@ export type Database = {jobStatus: Database["public"]["Enums"]["jobStatus"]jobDueDate: stringjobDeadlineType: Database["public"]["Enums"]["deadlineType"]+ jobCustomerId: string+ salesOrderReadableId: string+ salesOrderId: string+ salesOrderLineId: stringparentMaterialId: stringitemReadableId: string+ itemDescription: stringoperationStatus: Database["public"]["Enums"]["jobOperationStatus"]operationQuantity: numberquantityComplete: numberquantityScrapped: number+ thumbnailPath: string+ assignee: string+ tags: string[]}[]}get_active_job_operations_by_location: {@@ -32743,12 +32751,20 @@ export type Database = {jobStatus: Database["public"]["Enums"]["jobStatus"]jobDueDate: stringjobDeadlineType: Database["public"]["Enums"]["deadlineType"]+ jobCustomerId: string+ salesOrderReadableId: string+ salesOrderId: string+ salesOrderLineId: stringparentMaterialId: stringitemReadableId: string+ itemDescription: stringoperationStatus: Database["public"]["Enums"]["jobOperationStatus"]operationQuantity: numberquantityComplete: numberquantityScrapped: number+ thumbnailPath: string+ assignee: string+ tags: string[]}[]}groups_for_user: {diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.tsindex a866755545..354fd40a3e 100644--- a/packages/database/supabase/functions/lib/types.ts+++ b/packages/database/supabase/functions/lib/types.ts@@ -32412,12 +32412,20 @@ export type Database = {jobStatus: Database["public"]["Enums"]["jobStatus"]jobDueDate: stringjobDeadlineType: Database["public"]["Enums"]["deadlineType"]+ jobCustomerId: string+ salesOrderReadableId: string+ salesOrderId: string+ salesOrderLineId: stringparentMaterialId: stringitemReadableId: string+ itemDescription: stringoperationStatus: Database["public"]["Enums"]["jobOperationStatus"]operationQuantity: numberquantityComplete: numberquantityScrapped: number+ thumbnailPath: string+ assignee: string+ tags: string[]}[]}get_active_job_operations_by_location: {@@ -32743,12 +32751,20 @@ export type Database = {jobStatus: Database["public"]["Enums"]["jobStatus"]jobDueDate: stringjobDeadlineType: Database["public"]["Enums"]["deadlineType"]+ jobCustomerId: string+ salesOrderReadableId: string+ salesOrderId: string+ salesOrderLineId: stringparentMaterialId: stringitemReadableId: string+ itemDescription: stringoperationStatus: Database["public"]["Enums"]["jobOperationStatus"]operationQuantity: numberquantityComplete: numberquantityScrapped: number+ thumbnailPath: string+ assignee: string+ tags: string[]}[]}groups_for_user: {diff --git a/packages/database/supabase/migrations/20250123183808_add-image-to-recent-in-mes.sql b/packages/database/supabase/migrations/20250123183808_add-image-to-recent-in-mes.sqlnew file mode 100644index 0000000000..852417efc5--- /dev/null+++ b/packages/database/supabase/migrations/20250123183808_add-image-to-recent-in-mes.sql@@ -0,0 +1,309 @@+DROP FUNCTION IF EXISTS get_recent_job_operations_by_employee;+CREATE OR REPLACE FUNCTION get_recent_job_operations_by_employee(+ employee_id TEXT,+ company_id TEXT+)+RETURNS TABLE (+ "id" TEXT,+ "jobId" TEXT,+ "operationOrder" DOUBLE PRECISION,+ "processId" TEXT,+ "workCenterId" TEXT,+ "description" TEXT,+ "setupTime" NUMERIC(10,2),+ "setupUnit" factor,+ "laborTime" NUMERIC(10,2),+ "laborUnit" factor,+ "machineTime" NUMERIC(10,2),+ "machineUnit" factor,+ "operationOrderType" "methodOperationOrder",+ "jobReadableId" TEXT,+ "jobStatus" "jobStatus",+ "jobDueDate" DATE,+ "jobDeadlineType" "deadlineType",+ "jobCustomerId" TEXT,+ "salesOrderReadableId" TEXT,+ "salesOrderId" TEXT,+ "salesOrderLineId" TEXT,+ "parentMaterialId" TEXT,+ "itemReadableId" TEXT,+ "itemDescription" TEXT,+ "operationStatus" "jobOperationStatus",+ "operationQuantity" NUMERIC(10,2),+ "quantityComplete" NUMERIC(10,2),+ "quantityScrapped" NUMERIC(10,2),+ "thumbnailPath" TEXT,+ "assignee" TEXT,+ "tags" TEXT[]+)+SECURITY INVOKER+AS $$+BEGIN+ RETURN QUERY+ WITH recent_production_events AS (+ SELECT "jobOperationId", MAX("endTime") as "endTime"+ FROM "productionEvent"+ WHERE "employeeId" = employee_id AND "companyId" = company_id+ GROUP BY "jobOperationId"+ )+ SELECT+ jo."id",+ jo."jobId",+ jo."order" AS "operationOrder",+ jo."processId",+ jo."workCenterId",+ jo."description",+ jo."setupTime",+ jo."setupUnit",+ jo."laborTime",+ jo."laborUnit",+ jo."machineTime",+ jo."machineUnit",+ jo."operationOrder" AS "operationOrderType",+ j."jobId" AS "jobReadableId",+ j."status" AS "jobStatus",+ j."dueDate" AS "jobDueDate",+ j."deadlineType" AS "jobDeadlineType",+ j."customerId" AS "jobCustomerId",+ so."salesOrderId" AS "salesOrderReadableId",+ so."id" AS "salesOrderId",+ j."salesOrderLineId",+ jmm."parentMaterialId",+ i."readableId" as "itemReadableId",+ i."name" as "itemDescription",+ jo."status" AS "operationStatus",+ jo."operationQuantity",+ jo."quantityComplete",+ jo."quantityScrapped",+ CASE+ WHEN jmm."parentMaterialId" IS NULL THEN COALESCE(j_mu."thumbnailPath", i_mu."thumbnailPath")+ ELSE COALESCE(i."thumbnailPath", i_mu."thumbnailPath")+ END as "thumbnailPath",+ jo."assignee",+ jo."tags"+ FROM recent_production_events rpe+ JOIN "jobOperation" jo ON jo.id = rpe."jobOperationId"+ JOIN "job" j ON j.id = jo."jobId"+ LEFT JOIN "salesOrderLine" sol ON sol."id" = j."salesOrderLineId"+ LEFT JOIN "salesOrder" so ON so."id" = sol."salesOrderId"+ LEFT JOIN "jobMakeMethod" jmm ON jo."jobMakeMethodId" = jmm.id+ LEFT JOIN "item" i ON jmm."itemId" = i.id+ LEFT JOIN "modelUpload" j_mu ON j_mu.id = j."modelUploadId"+ LEFT JOIN "modelUpload" i_mu ON i_mu.id = i."modelUploadId"+ ORDER BY rpe."endTime" DESC+ LIMIT 20;+END;+$$ LANGUAGE plpgsql;+++DROP FUNCTION IF EXISTS get_active_job_operations_by_employee;+CREATE OR REPLACE FUNCTION get_active_job_operations_by_employee(+ employee_id TEXT,+ company_id TEXT+)+RETURNS TABLE (+ "id" TEXT,+ "jobId" TEXT,+ "operationOrder" DOUBLE PRECISION,+ "processId" TEXT,+ "workCenterId" TEXT,+ "description" TEXT,+ "setupTime" NUMERIC(10,2),+ "setupUnit" factor,+ "laborTime" NUMERIC(10,2),+ "laborUnit" factor,+ "machineTime" NUMERIC(10,2),+ "machineUnit" factor,+ "operationOrderType" "methodOperationOrder",+ "jobReadableId" TEXT,+ "jobStatus" "jobStatus",+ "jobDueDate" DATE,+ "jobDeadlineType" "deadlineType",+ "jobCustomerId" TEXT,+ "salesOrderReadableId" TEXT,+ "salesOrderId" TEXT,+ "salesOrderLineId" TEXT,+ "parentMaterialId" TEXT,+ "itemReadableId" TEXT,+ "itemDescription" TEXT,+ "operationStatus" "jobOperationStatus",+ "operationQuantity" NUMERIC(10,2),+ "quantityComplete" NUMERIC(10,2),+ "quantityScrapped" NUMERIC(10,2),+ "thumbnailPath" TEXT,+ "assignee" TEXT,+ "tags" TEXT[]+)+SECURITY INVOKER+AS $$+BEGIN+ RETURN QUERY+ WITH active_production_events AS (+ SELECT DISTINCT "jobOperationId"+ FROM "productionEvent"+ WHERE "employeeId" = employee_id AND "endTime" IS NULL AND "companyId" = company_id+ )+ SELECT+ jo."id",+ jo."jobId",+ jo."order" AS "operationOrder",+ jo."processId",+ jo."workCenterId",+ jo."description",+ jo."setupTime",+ jo."setupUnit",+ jo."laborTime",+ jo."laborUnit",+ jo."machineTime",+ jo."machineUnit",+ jo."operationOrder" AS "operationOrderType",+ j."jobId" AS "jobReadableId",+ j."status" AS "jobStatus",+ j."dueDate" AS "jobDueDate",+ j."deadlineType" AS "jobDeadlineType",+ j."customerId" AS "jobCustomerId",+ so."salesOrderId" AS "salesOrderReadableId",+ so."id" AS "salesOrderId",+ j."salesOrderLineId",+ jmm."parentMaterialId",+ i."readableId" as "itemReadableId",+ i."name" as "itemDescription",+ jo."status" AS "operationStatus",+ jo."operationQuantity",+ jo."quantityComplete",+ jo."quantityScrapped",+ CASE+ WHEN jmm."parentMaterialId" IS NULL THEN COALESCE(j_mu."thumbnailPath", i_mu."thumbnailPath")+ ELSE COALESCE(i."thumbnailPath", i_mu."thumbnailPath")+ END as "thumbnailPath",+ jo."assignee",+ jo."tags"+ FROM "jobOperation" jo+ JOIN "job" j ON j.id = jo."jobId"+ LEFT JOIN "salesOrderLine" sol ON sol."id" = j."salesOrderLineId"+ LEFT JOIN "salesOrder" so ON so."id" = sol."salesOrderId"+ LEFT JOIN "jobMakeMethod" jmm ON jo."jobMakeMethodId" = jmm.id+ LEFT JOIN "item" i ON jmm."itemId" = i.id+ LEFT JOIN "modelUpload" j_mu ON j_mu.id = j."modelUploadId"+ LEFT JOIN "modelUpload" i_mu ON i_mu.id = i."modelUploadId"+ JOIN active_production_events ape ON ape."jobOperationId" = jo.id;+END;+$$ LANGUAGE plpgsql;+++DROP FUNCTION IF EXISTS get_active_job_operations_by_location;+CREATE OR REPLACE FUNCTION get_active_job_operations_by_location(+ location_id TEXT,+ work_center_ids TEXT[]+)+RETURNS TABLE (+ "id" TEXT,+ "jobId" TEXT,+ "operationOrder" DOUBLE PRECISION,+ "priority" DOUBLE PRECISION,+ "processId" TEXT,+ "workCenterId" TEXT,+ "description" TEXT,+ "setupTime" NUMERIC(10,2),+ "setupUnit" factor,+ "laborTime" NUMERIC(10,2),+ "laborUnit" factor,+ "machineTime" NUMERIC(10,2),+ "machineUnit" factor,+ "operationOrderType" "methodOperationOrder",+ "jobMakeMethodId" TEXT,+ "assignee" TEXT,+ "tags" TEXT[],+ "jobReadableId" TEXT,+ "jobStatus" "jobStatus",+ "jobDueDate" DATE,+ "jobDeadlineType" "deadlineType",+ "jobCustomerId" TEXT,+ "salesOrderReadableId" TEXT,+ "salesOrderId" TEXT,+ "salesOrderLineId" TEXT,+ "parentMaterialId" TEXT,+ "itemReadableId" TEXT,+ "itemDescription" TEXT,+ "operationStatus" "jobOperationStatus",+ "operationQuantity" NUMERIC(10,2),+ "quantityComplete" NUMERIC(10,2),+ "quantityScrapped" NUMERIC(10,2),+ "thumbnailPath" TEXT+)+SECURITY INVOKER+AS $$+BEGIN+ RETURN QUERY+ WITH relevant_jobs AS (+ SELECT+ j."id",+ j."jobId",+ j."status",+ j."dueDate",+ j."deadlineType",+ j."customerId",+ so."salesOrderId" AS "salesOrderReadableId",+ so."id" AS "salesOrderId",+ j."salesOrderLineId",+ mu."thumbnailPath"+ FROM "job" j+ LEFT JOIN "salesOrderLine" sol ON sol."id" = j."salesOrderLineId"+ LEFT JOIN "salesOrder" so ON so."id" = sol."salesOrderId"+ LEFT JOIN "modelUpload" mu ON mu.id = j."modelUploadId"+ WHERE j."locationId" = location_id+ AND (j."status" = 'Ready' OR j."status" = 'In Progress' OR j."status" = 'Paused')+ )+ SELECT+ jo."id",+ jo."jobId",+ jo."order" AS "operationOrder",+ jo."priority",+ jo."processId",+ jo."workCenterId",+ jo."description",+ jo."setupTime",+ jo."setupUnit",+ jo."laborTime",+ jo."laborUnit",+ jo."machineTime",+ jo."machineUnit",+ jo."operationOrder" AS "operationOrderType",+ jo."jobMakeMethodId",+ jo."assignee",+ jo."tags",+ rj."jobId" AS "jobReadableId",+ rj."status" AS "jobStatus",+ rj."dueDate" AS "jobDueDate",+ rj."deadlineType" AS "jobDeadlineType",+ rj."customerId" AS "jobCustomerId",+ rj."salesOrderReadableId",+ rj."salesOrderId",+ rj."salesOrderLineId",+ jmm."parentMaterialId",+ i."readableId" as "itemReadableId",+ i."name" as "itemDescription",+ CASE+ WHEN rj."status" = 'Paused' THEN 'Paused'+ ELSE jo."status"+ END AS "operationStatus",+ jo."operationQuantity",+ jo."quantityComplete",+ jo."quantityScrapped",+ CASE+ WHEN jmm."parentMaterialId" IS NULL THEN COALESCE(rj."thumbnailPath", mu."thumbnailPath")+ ELSE COALESCE(i."thumbnailPath", mu."thumbnailPath")+ END as "thumbnailPath"+ FROM "jobOperation" jo+ JOIN relevant_jobs rj ON rj.id = jo."jobId"+ LEFT JOIN "jobMakeMethod" jmm ON jo."jobMakeMethodId" = jmm.id+ LEFT JOIN "item" i ON jmm."itemId" = i.id+ LEFT JOIN "modelUpload" mu ON mu.id = i."modelUploadId"+ WHERE CASE+ WHEN array_length(work_center_ids, 1) > 0 THEN+ jo."workCenterId" = ANY(work_center_ids) AND jo."status" != 'Done' AND jo."status" != 'Canceled'+ ELSE jo."status" != 'Done' AND jo."status" != 'Canceled'+ END+ ORDER BY jo."priority";+END;+$$ LANGUAGE plpgsql;\ No newline at end of file