test(ocp): working on more migrations

This commit is contained in:
2025-04-04 17:13:15 -05:00
parent a7818b4ca3
commit 9f26f2334f
8 changed files with 224 additions and 16 deletions

View File

@@ -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 };
};

View 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.
*/
};

View File

@@ -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,