test(ocp): working on more migrations
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { eq, gte, sql } from "drizzle-orm";
|
||||
import { db } from "../../../../../database/dbclient.js";
|
||||
import { printers } from "../../../../../database/schema/printers.js";
|
||||
import { printerData } from "../../../../../database/schema/printers.js";
|
||||
import { tryCatch } from "../../../../globalUtils/tryCatch.js";
|
||||
import { createLog } from "../../../logger/logger.js";
|
||||
import { prodEndpointCreation } from "../../../../globalUtils/createUrl.js";
|
||||
@@ -15,8 +15,8 @@ export const createLabel = async (data: any, userPrinted: any) => {
|
||||
const { data: printer, error: printerError } = await tryCatch(
|
||||
db
|
||||
.select()
|
||||
.from(printers)
|
||||
.where(eq(printers.humanReadableId, data.printerID))
|
||||
.from(printerData)
|
||||
.where(eq(printerData.humanReadableId, data.printerID))
|
||||
);
|
||||
const { data: settingsData, error: settingsError } = await tryCatch(
|
||||
db.select().from(settings)
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
import { db } from "../../../../../database/dbclient.js";
|
||||
import { tryCatch } from "../../../../globalUtils/tryCatch.js";
|
||||
import { printers } from "../../../../../database/schema/printers.js";
|
||||
import { printerData } from "../../../../../database/schema/printers.js";
|
||||
|
||||
export const getPrinters = async () => {
|
||||
const currentTime = new Date(Date.now());
|
||||
|
||||
const { data: printerData, error: printerError } = await tryCatch(
|
||||
db.select().from(printers)
|
||||
const { data: printers, error: printerError } = await tryCatch(
|
||||
db.select().from(printerData)
|
||||
);
|
||||
|
||||
if (printerError) {
|
||||
@@ -17,5 +15,5 @@ export const getPrinters = async () => {
|
||||
};
|
||||
}
|
||||
|
||||
return { success: true, message: "Printers", data: printerData };
|
||||
return { success: true, message: "Printers", data: printers };
|
||||
};
|
||||
|
||||
20
server/services/ocp/controller/printers/printerCycle.ts
Normal file
20
server/services/ocp/controller/printers/printerCycle.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { getPrinters } from "./getPrinters.js";
|
||||
|
||||
export const printerCycle = async () => {
|
||||
/**
|
||||
* We will cycle through the printers to check there states.
|
||||
*/
|
||||
let printers = await getPrinters();
|
||||
/**
|
||||
* if the last timeprinted would be greater than x well just change the status to idle and extended based on the 2 times.
|
||||
*
|
||||
* to get a printer going again label will need to come from the front end as that will just unpause the printer and start the labeling, or the api for manual print
|
||||
* well need to adjust this to actually print the label then unpause it.
|
||||
*
|
||||
* it will be
|
||||
*
|
||||
* less than x since time printed run the printer status
|
||||
* greater than x but less than y change the status to idle, but ping to make sure its online,
|
||||
* if greater than y change to extended idle but stil also ping to make sure its online.
|
||||
*/
|
||||
};
|
||||
@@ -1,6 +1,5 @@
|
||||
import { printers } from "../../../../../database/schema/printers.js";
|
||||
import axios from "axios";
|
||||
|
||||
import { printerData } from "../../../../../database/schema/printers.js";
|
||||
import { sql } from "drizzle-orm";
|
||||
import { prodEndpointCreation } from "../../../../globalUtils/createUrl.js";
|
||||
import { tryCatch } from "../../../../globalUtils/tryCatch.js";
|
||||
@@ -47,10 +46,10 @@ export const updatePrinters = async () => {
|
||||
};
|
||||
const { data, error } = await tryCatch(
|
||||
db
|
||||
.insert(printers)
|
||||
.insert(printerData)
|
||||
.values(printerStuff)
|
||||
.onConflictDoUpdate({
|
||||
target: printers.humanReadableId,
|
||||
target: printerData.humanReadableId,
|
||||
set: {
|
||||
//humanReadableId: prodPrinterInfo[i].humanReadableId,
|
||||
name: prodPrinterInfo[i].name,
|
||||
|
||||
Reference in New Issue
Block a user