feat(db cleanup): added a cleanup for labels this checks daily
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { eq, gte, sql } from "drizzle-orm";
|
||||
import { eq, gte, lt, sql } from "drizzle-orm";
|
||||
import { db } from "../../../../../database/dbclient.js";
|
||||
import { printerData } from "../../../../../database/schema/printers.js";
|
||||
import { tryCatch } from "../../../../globalUtils/tryCatch.js";
|
||||
@@ -8,6 +8,7 @@ import { settings } from "../../../../../database/schema/settings.js";
|
||||
import { lstAuth } from "../../../../index.js";
|
||||
import axios from "axios";
|
||||
import { prodlabels } from "../../../../../database/schema/prodLabels.js";
|
||||
import { addDays } from "date-fns";
|
||||
|
||||
export const createLabel = async (data: any, userPrinted: any) => {
|
||||
createLog("info", "labeling", "ocp", `Label being created`);
|
||||
@@ -147,22 +148,3 @@ export const createLabel = async (data: any, userPrinted: any) => {
|
||||
};
|
||||
|
||||
// run the label delete process we want to delate them older than 90 days right now
|
||||
const deleteLabels = async () => {
|
||||
/**
|
||||
* Deletes labels older than 90 days from lst... all label data can be found in alpla prod.
|
||||
*/
|
||||
try {
|
||||
await db
|
||||
.delete(prodlabels)
|
||||
.where(
|
||||
gte(prodlabels.upd_date, sql.raw(`NOW() - INTERVAL '90 days'`))
|
||||
);
|
||||
} catch (error) {
|
||||
createLog(
|
||||
"error",
|
||||
"labeling",
|
||||
"ocp",
|
||||
`Error deleting labels older than 90 days`
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user