130 lines
3.6 KiB
TypeScript
130 lines
3.6 KiB
TypeScript
import { db } from "../../../../database/dbclient.js";
|
|
import { notifications } from "../../../../database/schema/notifications.js";
|
|
import { createLog } from "../../logger/logger.js";
|
|
|
|
export const note: any = [
|
|
{
|
|
name: "reprintLabels",
|
|
description:
|
|
"Monitors the labels that are printed and returns a value if one falls withing the time frame defined below.",
|
|
checkInterval: 1,
|
|
timeType: "min",
|
|
emails: "",
|
|
active: false,
|
|
notifiySettings: { prodID: 1 },
|
|
},
|
|
{
|
|
name: "downTimeCheck",
|
|
description:
|
|
"Checks for specific downtimes that are greater than 105 min.",
|
|
checkInterval: 30,
|
|
timeType: "min",
|
|
emails: "",
|
|
active: false,
|
|
notifiySettings: { prodID: 1, daysInPast: 5, duration: 105 },
|
|
},
|
|
{
|
|
name: "qualityBlocking",
|
|
description:
|
|
"Checks for new blocking orders that have been entered, recommened to get the most recent order in here before activating.",
|
|
checkInterval: 30,
|
|
timeType: "min",
|
|
emails: "",
|
|
active: false,
|
|
notifiySettings: {
|
|
prodID: 1,
|
|
sentBlockingOrders: [{ timeStamp: "0", blockingOrder: 1 }],
|
|
},
|
|
},
|
|
{
|
|
name: "productionCheck",
|
|
description: "Checks ppoo",
|
|
checkInterval: 2,
|
|
timeType: "hour",
|
|
emails: "",
|
|
active: false,
|
|
notifiySettings: {
|
|
prodID: 1,
|
|
count: 0,
|
|
weekend: false,
|
|
locations: "0",
|
|
},
|
|
},
|
|
{
|
|
name: "stagingCheck",
|
|
description:
|
|
"Checks staging based on locations, locations need to be seperated by a ,",
|
|
checkInterval: 2,
|
|
timeType: "hour",
|
|
emails: "",
|
|
active: false,
|
|
notifiySettings: {
|
|
prodID: 1,
|
|
count: 0,
|
|
weekend: false,
|
|
locations: "0",
|
|
},
|
|
},
|
|
{
|
|
name: "tiIntergration",
|
|
description: "Checks for new releases to be put into ti",
|
|
checkInterval: 2,
|
|
timeType: "hour",
|
|
emails: "",
|
|
active: false,
|
|
notifiySettings: {
|
|
prodID: 1,
|
|
start: 36,
|
|
end: 36,
|
|
releases: [{ timeStamp: "0", releaseNumber: 1 }],
|
|
},
|
|
},
|
|
{
|
|
name: "exampleNotification",
|
|
description: "Checks for new releases to be put into ti",
|
|
checkInterval: 2,
|
|
timeType: "min",
|
|
emails: "",
|
|
active: true,
|
|
notifiySettings: {
|
|
prodID: 1,
|
|
start: 36,
|
|
end: 36,
|
|
releases: [1, 2, 3],
|
|
},
|
|
},
|
|
];
|
|
|
|
export const notificationCreate = async () => {
|
|
for (let i = 0; i < note.length; i++) {
|
|
try {
|
|
const notify = await db
|
|
.insert(notifications)
|
|
.values(note[i])
|
|
.onConflictDoUpdate({
|
|
target: notifications.name,
|
|
set: {
|
|
name: note[i].name,
|
|
description: note[i].description,
|
|
//notifiySettings: note[i].notifiySettings,
|
|
},
|
|
});
|
|
} catch (error) {
|
|
createLog(
|
|
"error",
|
|
"notify",
|
|
"notify",
|
|
`There was an error getting the notifications: ${JSON.stringify(
|
|
error
|
|
)}`
|
|
);
|
|
}
|
|
}
|
|
createLog(
|
|
"info",
|
|
"lst",
|
|
"nofity",
|
|
"notifications were just added/updated due to server startup"
|
|
);
|
|
};
|