43 lines
995 B
TypeScript
43 lines
995 B
TypeScript
import { tryCatch } from "../../../globalUtils/tryCatch.js";
|
|
import { createLog } from "../../logger/logger.js";
|
|
import { query } from "../../sqlServer/prodSqlServer.js";
|
|
import { forecastData } from "../../sqlServer/querys/psiReport/forecast.js";
|
|
|
|
// type ArticleData = {
|
|
// id: string
|
|
// }
|
|
export const getGetPSIForecastData = async (customer: string) => {
|
|
let articles: any = [];
|
|
let queryData = forecastData;
|
|
console.log(customer);
|
|
if (customer) {
|
|
queryData = forecastData.replace("[customer]", customer);
|
|
}
|
|
|
|
const { data, error } = (await tryCatch(
|
|
query(queryData, "PSI forecast info"),
|
|
)) as any;
|
|
|
|
if (error) {
|
|
createLog(
|
|
"error",
|
|
"datamart",
|
|
"datamart",
|
|
`There was an error getting the forecast info: ${JSON.stringify(error)}`,
|
|
);
|
|
return {
|
|
success: false,
|
|
messsage: `There was an error getting the forecast info`,
|
|
data: error,
|
|
};
|
|
}
|
|
|
|
articles = data.data;
|
|
|
|
return {
|
|
success: true,
|
|
message: "PSI forecast Data",
|
|
data: articles,
|
|
};
|
|
};
|