refactor(printdelay): added in a change to allow override the actualy time
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
import {
|
||||
text,
|
||||
pgTable,
|
||||
numeric,
|
||||
index,
|
||||
timestamp,
|
||||
boolean,
|
||||
uuid,
|
||||
uniqueIndex,
|
||||
index,
|
||||
jsonb,
|
||||
numeric,
|
||||
pgTable,
|
||||
text,
|
||||
timestamp,
|
||||
uniqueIndex,
|
||||
uuid,
|
||||
} from "drizzle-orm/pg-core";
|
||||
import { createInsertSchema, createSelectSchema } from "drizzle-zod";
|
||||
import { z } from "zod";
|
||||
@@ -28,13 +28,14 @@ export const printerData = pgTable(
|
||||
printDelay: numeric("printDelay").default("90"),
|
||||
monitorState: boolean("monitorState").default(false),
|
||||
processes: jsonb("processes").default([]),
|
||||
printDelayOverride: boolean("print_delay_override").default(false), // this will be more for if we have the lot time active but want to over ride this single line for some reason
|
||||
add_Date: timestamp("add_Date").defaultNow(),
|
||||
upd_date: timestamp("upd_date").defaultNow(),
|
||||
},
|
||||
(table) => [
|
||||
//uniqueIndex("emailUniqueIndex").on(sql`lower(${table.email})`),
|
||||
uniqueIndex("humanReadableId").on(table.humanReadableId),
|
||||
]
|
||||
],
|
||||
);
|
||||
|
||||
// Schema for inserting a user - can be used to validate API requests
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import { eq, sql } from "drizzle-orm";
|
||||
import { and, eq, sql } from "drizzle-orm";
|
||||
import { db } from "../../../../database/dbclient.js";
|
||||
import { printerData } from "../../../../database/schema/printers.js";
|
||||
import { settings } from "../../../../database/schema/settings.js";
|
||||
import { delay } from "../../../globalUtils/delay.js";
|
||||
import { tryCatch } from "../../../globalUtils/tryCatch.js";
|
||||
import { createLog } from "../../logger/logger.js";
|
||||
import { delay } from "../../../globalUtils/delay.js";
|
||||
import { getPrinters } from "../controller/printers/getPrinters.js";
|
||||
|
||||
//**The logic here will be when the setting is active to utilize the lots times it will update the printDelay in the printer data table */
|
||||
export const printerDelayByLot = async (lot: any) => {
|
||||
const { data: settingData, error: settingError } = await tryCatch(
|
||||
db.select().from(settings)
|
||||
db.select().from(settings),
|
||||
);
|
||||
|
||||
if (settingError) {
|
||||
@@ -46,8 +46,11 @@ export const printerDelayByLot = async (lot: any) => {
|
||||
upd_date: sql`NOW()`,
|
||||
})
|
||||
.where(
|
||||
eq(printerData.humanReadableId, lot[i].printerID)
|
||||
)
|
||||
and(
|
||||
eq(printerData.humanReadableId, lot[i].printerID),
|
||||
eq(printerData.printDelayOverride, false),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// if (data) {
|
||||
@@ -83,7 +86,12 @@ export const printerDelayByLot = async (lot: any) => {
|
||||
printDelay: lot[i].timeTOmakeInSeconds,
|
||||
upd_date: sql`NOW()`,
|
||||
})
|
||||
.where(eq(printerData.humanReadableId, lot[i].printerID))
|
||||
.where(
|
||||
and(
|
||||
eq(printerData.humanReadableId, lot[i].printerID),
|
||||
eq(printerData.printDelayOverride, false),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// if (data) {
|
||||
|
||||
Reference in New Issue
Block a user