Add query time tracking to IO Events.
This commit is contained in:
@@ -778,3 +778,10 @@ exports.QUERY_JOB_COSTING_DETAILS_MULTI = ` query QUERY_JOB_COSTING_DETAILS_MULT
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
exports.INSERT_IOEVENT = ` mutation INSERT_IOEVENT($event: ioevents_insert_input!) {
|
||||
insert_ioevents_one(object: $event) {
|
||||
id
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
29
server/ioevent/ioevent.js
Normal file
29
server/ioevent/ioevent.js
Normal file
@@ -0,0 +1,29 @@
|
||||
const client = require("../graphql-client/graphql-client").client;
|
||||
const queries = require("../graphql-client/queries");
|
||||
const path = require("path");
|
||||
|
||||
require("dotenv").config({
|
||||
path: path.resolve(
|
||||
process.cwd(),
|
||||
`.env.${process.env.NODE_ENV || "development"}`
|
||||
),
|
||||
});
|
||||
|
||||
exports.default = async (req, res) => {
|
||||
const { operationName, time, dbevent } = req.body;
|
||||
|
||||
try {
|
||||
await client.request(queries.INSERT_IOEVENT, {
|
||||
event: {
|
||||
operationname: operationName,
|
||||
time,
|
||||
dbevent,
|
||||
},
|
||||
});
|
||||
|
||||
res.sendStatus(200);
|
||||
} catch (error) {
|
||||
console.log("error", error);
|
||||
res.status(400).send(error);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user