refactor(sql): improved the return function to show data [] when not connected, prevents crashes
This commit is contained in:
@@ -81,11 +81,11 @@ export default async function reprintLabelMonitor(notifyData: any) {
|
||||
`;
|
||||
|
||||
//console.log(query);
|
||||
let downTime: any; //DownTime[];
|
||||
let downTime: any = []; //DownTime[];
|
||||
try {
|
||||
downTime = await query(dQuery, "downTimeCheck");
|
||||
const res: any = await query(dQuery, "downTimeCheck");
|
||||
//console.log(labels.length);
|
||||
|
||||
downTime = res.data;
|
||||
if (
|
||||
downTime.length > 0 &&
|
||||
downTime[0]?.downTimeId > notifyData.notifiySettings.prodID
|
||||
|
||||
@@ -76,7 +76,8 @@ export default async function reprintLabelMonitor(notifyData: any) {
|
||||
|
||||
let prod: PPOO[];
|
||||
try {
|
||||
prod = await query(notifyQuery, "Label Reprints");
|
||||
const res: any = await query(notifyQuery, "Label Reprints");
|
||||
prod = res.data;
|
||||
//console.log(labels.length);
|
||||
// const now = Date.now()
|
||||
if (prod.length > 0) {
|
||||
|
||||
@@ -44,10 +44,10 @@ export default async function qualityBlockingMonitor(notifyData: any) {
|
||||
blockingOrders
|
||||
);
|
||||
|
||||
const { data: blocking, error: blockingError } = await tryCatch(
|
||||
const { data: b, error: blockingError } = await tryCatch(
|
||||
query(blockingQuery, "Quality Blocking")
|
||||
);
|
||||
|
||||
const blocking: any = b?.data as any;
|
||||
if (blockingError) {
|
||||
return {
|
||||
success: false,
|
||||
|
||||
@@ -64,10 +64,10 @@ const notification = async (notifyData: any) => {
|
||||
|
||||
//let labels: Labels[];
|
||||
|
||||
const { data: labels, error: labelError } = await tryCatch(
|
||||
const { data: l, error: labelError } = await tryCatch(
|
||||
query(reprintQuery, "Label Reprints")
|
||||
);
|
||||
|
||||
const labels: any = l?.data as any;
|
||||
if (labelError) {
|
||||
createLog(
|
||||
"error",
|
||||
|
||||
@@ -69,7 +69,8 @@ export default async function reprintLabelMonitor(notifyData: any) {
|
||||
|
||||
let stage: PPOO[];
|
||||
try {
|
||||
stage = await query(noteQuery, "Staging checks");
|
||||
const res = await query(noteQuery, "Staging checks");
|
||||
stage = res?.data as any;
|
||||
//console.log(labels.length);
|
||||
// const now = Date.now()
|
||||
if (stage.length > 0) {
|
||||
|
||||
@@ -77,9 +77,11 @@ export const tiImport = async () => {
|
||||
.replaceAll("[exclude]", releaseString);
|
||||
|
||||
// get the headers pending
|
||||
const { data: header, error: headerError } = await tryCatch(
|
||||
const { data: h, error: headerError } = await tryCatch(
|
||||
query(orders, "Ti get open headers")
|
||||
);
|
||||
const header: any = h?.data as any;
|
||||
|
||||
if (headerError) {
|
||||
createLog(
|
||||
"error",
|
||||
@@ -127,9 +129,11 @@ export const tiImport = async () => {
|
||||
.replaceAll("[to]", notiSet[0].notifiySettings.end);
|
||||
|
||||
// get the headers pending
|
||||
const { data: orderData, error: ordersError } = await tryCatch(
|
||||
const { data: o, error: ordersError } = await tryCatch(
|
||||
query(orderToSend, "Ti get open headers")
|
||||
);
|
||||
|
||||
const orderData: any = o?.data as any;
|
||||
if (ordersError)
|
||||
return {
|
||||
success: false,
|
||||
|
||||
Reference in New Issue
Block a user