Added timing for job costing.
This commit is contained in:
@@ -11,6 +11,7 @@ Dinero.globalRoundingMode = "HALF_EVEN";
|
||||
async function JobCosting(req, res) {
|
||||
const { jobid } = req.body;
|
||||
console.log("🚀 ~ file: job-costing.js ~ line 13 ~ jobid", jobid);
|
||||
console.time("querydata");
|
||||
const BearerToken = req.headers.authorization;
|
||||
|
||||
const client = new GraphQLClient(process.env.GRAPHQL_ENDPOINT, {
|
||||
@@ -25,8 +26,11 @@ async function JobCosting(req, res) {
|
||||
.request(queries.QUERY_JOB_COSTING_DETAILS, {
|
||||
id: jobid,
|
||||
});
|
||||
console.timeEnd("querydata");
|
||||
|
||||
console.time(`generatecostingdata-${resp.jobs_by_pk.id}`);
|
||||
const ret = GenerateCostingData(resp.jobs_by_pk);
|
||||
console.timeEnd(`generatecostingdata-${resp.jobs_by_pk.id}`);
|
||||
|
||||
res.status(200).json(ret);
|
||||
} catch (error) {
|
||||
@@ -37,9 +41,8 @@ async function JobCosting(req, res) {
|
||||
|
||||
async function JobCostingMulti(req, res) {
|
||||
const { jobids } = req.body;
|
||||
console.log("🚀 ~ file: job-costing.js ~ line 13 ~ jobids", jobids);
|
||||
const BearerToken = req.headers.authorization;
|
||||
|
||||
console.time("JobCostingMultiQueryExecution");
|
||||
const client = new GraphQLClient(process.env.GRAPHQL_ENDPOINT, {
|
||||
headers: {
|
||||
Authorization: BearerToken,
|
||||
@@ -56,9 +59,13 @@ async function JobCostingMulti(req, res) {
|
||||
//for Each!***************
|
||||
const ret = {};
|
||||
resp.jobs.map((job) => {
|
||||
console.time(`CostingData-${job.id}`);
|
||||
ret[job.id] = GenerateCostingData(job);
|
||||
console.timeEnd(`CostingData-${job.id}`);
|
||||
});
|
||||
|
||||
console.timeEnd("JobCostingMultiQueryExecution");
|
||||
|
||||
res.status(200).json(ret);
|
||||
} catch (error) {
|
||||
console.log("error", error);
|
||||
|
||||
Reference in New Issue
Block a user