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:
Dave Richer
2024-09-11 20:27:40 -04:00
parent f606228792
commit 4486858a86
5 changed files with 186 additions and 102 deletions

View File

@@ -12,7 +12,7 @@ const CalculateAllocations = require("../../cdk/cdk-calculate-allocations").defa
const CdkBase = require("../../web-sockets/web-socket");
const moment = require("moment-timezone");
const Dinero = require("dinero.js");
const { setSessionData, getSessionData } = require("../../../server");
const { setSessionData, getSessionData, getMultipleSessionData, setMultipleSessionData } = require("../../../server");
const InstanceManager = require("../../utils/instanceMgr").default;
const axios = AxiosLib.create();
@@ -60,9 +60,10 @@ axios.interceptors.response.use(
exports.default = async function (socket, { txEnvelope, jobid }) {
try {
await setSessionData(socket.id, "logEvents", []);
await setSessionData(socket.id, "recordid", jobid);
await setSessionData(socket.id, "txEnvelope", txEnvelope);
await setMultipleSessionData(socket.id, {
recordid: jobid,
txEnvelope
});
await CdkBase.createLogEvent(socket, "DEBUG", `Received Job export request for id ${jobid}`);
@@ -536,8 +537,7 @@ async function UpsertVehicleData(socket, ownerRef) {
async function InsertAccountPostingData(socket) {
try {
const JobData = await getSessionData(socket.id, "JobData");
const txEnvelope = await getSessionData(socket.id, "txEnvelope");
const { JobData, txEnvelope } = await getMultipleSessionData(socket.id, ["JobData", "txEnvelope"]);
const allocations = await CalculateAllocations(socket, JobData.id);
@@ -650,8 +650,9 @@ async function InsertAccountPostingData(socket) {
async function MarkJobExported(socket, jobid) {
await CdkBase.createLogEvent(socket, "DEBUG", `Marking job as exported for id ${jobid}`);
const client = new GraphQLClient(process.env.GRAPHQL_ENDPOINT, {});
const JobData = await getSessionData(socket.id, "JobData");
const transWips = await getSessionData(socket.id, "transWips");
const { JobData, transWips } = await getMultipleSessionData(socket.id, ["JobData", "transWips"]);
return await client
.setHeaders({ Authorization: `Bearer ${socket.handshake.auth.token}` })
.request(queries.MARK_JOB_EXPORTED, {