feature/IO-2742-redis - Checkpoint, All optimizations to prevent multiple requests to redis have been applied. Things like using lists for the Log Events, to getting and setting multiple values at the same time when given the chance.
Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
@@ -12,7 +12,7 @@ const AxiosLib = require("axios").default;
|
||||
const axios = AxiosLib.create();
|
||||
const { PBS_ENDPOINTS, PBS_CREDENTIALS } = require("./pbs-constants");
|
||||
const { CheckForErrors } = require("./pbs-job-export");
|
||||
const { getSessionData, setSessionData } = require("../../../server");
|
||||
const { getSessionData, getMultipleSessionData, setMultipleSessionData } = require("../../../server");
|
||||
const uuid = require("uuid").v4;
|
||||
|
||||
axios.interceptors.request.use(
|
||||
@@ -66,8 +66,10 @@ async function PbsCalculateAllocationsAp(socket, billids) {
|
||||
const { bills, bodyshops } = await QueryBillData(socket, billids);
|
||||
const bodyshop = bodyshops[0];
|
||||
|
||||
await setSessionData(socket.id, "bills", bills);
|
||||
await setSessionData(socket.id, "bodyshop", bodyshop);
|
||||
await setMultipleSessionData(socket.id, {
|
||||
bills,
|
||||
bodyshop
|
||||
});
|
||||
|
||||
const txEnvelope = await getSessionData(socket.id, "txEnvelope");
|
||||
|
||||
@@ -221,12 +223,12 @@ function getCostAccount(billline, respcenters) {
|
||||
exports.PbsExportAp = async function (socket, { billids, txEnvelope }) {
|
||||
await CdkBase.createLogEvent(socket, "DEBUG", `Exporting selected AP.`);
|
||||
|
||||
//apAllocations has the same shape as the lines key for the accounting posting to PBS.
|
||||
const apAllocations = await PbsCalculateAllocationsAp(socket, billids);
|
||||
await setSessionData(socket.id, "apAllocations", apAllocations);
|
||||
|
||||
// Store txEnvelope in session
|
||||
await setSessionData(socket.id, "txEnvelope", txEnvelope);
|
||||
await setMultipleSessionData(socket.id, {
|
||||
apAllocations,
|
||||
txEnvelope
|
||||
});
|
||||
|
||||
for (const allocation of apAllocations) {
|
||||
const { billid, ...restAllocation } = allocation;
|
||||
@@ -257,8 +259,7 @@ exports.PbsExportAp = async function (socket, { billids, txEnvelope }) {
|
||||
};
|
||||
|
||||
async function MarkApExported(socket, billids) {
|
||||
const bills = await getSessionData(socket.id, "bills");
|
||||
const bodyshop = await getSessionData(socket.id, "bodyshop");
|
||||
const { bills, bodyshop } = await getMultipleSessionData(socket.id, ["bills", "bodyshop"]);
|
||||
|
||||
await CdkBase.createLogEvent(socket, "DEBUG", `Marking bills as exported for id ${billids}`);
|
||||
const client = new GraphQLClient(process.env.GRAPHQL_ENDPOINT, {});
|
||||
|
||||
Reference in New Issue
Block a user