From c1b119e7acb9ea2e6b7b32817d0258a274447ea0 Mon Sep 17 00:00:00 2001 From: "Michael.Taylor" Date: Wed, 15 Dec 2021 17:56:39 -0500 Subject: [PATCH] chore: remove extraneous file --- 0001-feat-handle-staging-commit.patch | 239 -------------------------- 1 file changed, 239 deletions(-) delete mode 100644 0001-feat-handle-staging-commit.patch diff --git a/0001-feat-handle-staging-commit.patch b/0001-feat-handle-staging-commit.patch deleted file mode 100644 index 1f0e2416..00000000 --- a/0001-feat-handle-staging-commit.patch +++ /dev/null @@ -1,239 +0,0 @@ -From cb688a5c41d4c50d7b26f58130baab98d54feff3 Mon Sep 17 00:00:00 2001 -From: "Michael.Taylor" -Date: Wed, 15 Dec 2021 17:14:53 -0500 -Subject: [PATCH] feat: handle staging commit - ---- - src/controllers/staging.controller.js | 27 ++++++++---- - src/fullnode/fullnode.js | 24 +++++------ - src/fullnode/simulator.js | 62 ++++++++++++++++++++++++--- - 3 files changed, 86 insertions(+), 27 deletions(-) - -diff --git a/src/controllers/staging.controller.js b/src/controllers/staging.controller.js -index 1307d04..2cff3bb 100644 ---- a/src/controllers/staging.controller.js -+++ b/src/controllers/staging.controller.js -@@ -55,36 +55,47 @@ export const commit = async (req, res) => { - const queryResponse = await Staging.findAll(); - const stagingRecords = queryResponse.dataValues; - stagingRecords.forEach(async (stagingRecord) => { -- const { uuid, table, action, data: rawData } = stagingRecord; -+ const { -+ id: stagingRecordId, -+ uuid, -+ table, -+ action, -+ data: rawData, -+ } = stagingRecord; - const data = JSON.parse(rawData); - -+ await Staging.update( -+ { commited: true }, -+ { where: { id: stagingRecordId } }, -+ ); -+ - if (table === 'Projects') { - switch (action) { - case 'INSERT': -- fullNode.createProjectRecord(uuid, data); -+ fullNode.createProjectRecord(uuid, data, stagingRecordId); - break; - case 'UPDATE': -- fullNode.updateProjectRecord(uuid, data); -+ fullNode.updateProjectRecord(uuid, data, stagingRecordId); - break; - case 'DELETE': -- fullNode.deleteProjectRecord(uuid); -+ fullNode.deleteProjectRecord(uuid, stagingRecordId); - break; - } - } else if (table === 'Unit') { - switch (action) { - case 'INSERT': -- fullNode.createUnitRecord(uuid, data); -+ fullNode.createUnitRecord(uuid, data, stagingRecordId); - break; - case 'UPDATE': -- fullNode.updateUnitRecord(uuid, data); -+ fullNode.updateUnitRecord(uuid, data, stagingRecordId); - break; - case 'DELETE': -- fullNode.deleteUnitRecord(uuid); -+ fullNode.deleteUnitRecord(uuid, stagingRecordId); - break; - } - } - }); -- res.json({ message: 'Not implemented' }); -+ res.json({ message: 'Staging Table commited to fullnode' }); - }; - - export const destroy = (req, res) => { -diff --git a/src/fullnode/fullnode.js b/src/fullnode/fullnode.js -index 4ed8e3d..ce77bc5 100644 ---- a/src/fullnode/fullnode.js -+++ b/src/fullnode/fullnode.js -@@ -1,25 +1,25 @@ - import * as simulator from './simulator'; - --export const updateProjectRecord = async (uuid, record) => { -- await simulator.updateProjectRecord(uuid, record); -+export const updateProjectRecord = async (uuid, record, stagingRecordId) => { -+ await simulator.updateProjectRecord(uuid, record, stagingRecordId); - }; - --export const createProjectRecord = async (uuid, record) => { -- await simulator.createProjectRecord(uuid, record); -+export const createProjectRecord = async (uuid, record, stagingRecordId) => { -+ await simulator.createProjectRecord(uuid, record, stagingRecordId); - }; - --export const deleteProjectRecord = async (uuid) => { -- await simulator.deleteProjectRecord(uuid); -+export const deleteProjectRecord = async (uuid, stagingRecordId) => { -+ await simulator.deleteProjectRecord(uuid, stagingRecordId); - }; - --export const updateUnitRecord = async (uuid, record) => { -- await simulator.updateUnitRecord(uuid, record); -+export const updateUnitRecord = async (uuid, record, stagingRecordId) => { -+ await simulator.updateUnitRecord(uuid, record, stagingRecordId); - }; - --export const createUnitRecord = async (uuid, record) => { -- await simulator.createUnitRecord(uuid, record); -+export const createUnitRecord = async (uuid, record, stagingRecordId) => { -+ await simulator.createUnitRecord(uuid, record, stagingRecordId); - }; - --export const deleteUnitRecord = async (uuid) => { -- await simulator.deleteUnitRecord(uuid); -+export const deleteUnitRecord = async (uuid, stagingRecordId) => { -+ await simulator.deleteUnitRecord(uuid, stagingRecordId); - }; -diff --git a/src/fullnode/simulator.js b/src/fullnode/simulator.js -index 9d6e093..887733e 100644 ---- a/src/fullnode/simulator.js -+++ b/src/fullnode/simulator.js -@@ -1,26 +1,42 @@ --import { Project, Unit } from '../models'; -+import { Project, Unit, Staging } from '../models'; - const THIRTY_SEC = 30000; - - // Simulate 30 seconds passing before commited to node - --export const updateProjectRecord = async (uuid, record) => { -+export const updateProjectRecord = async (uuid, record, stagingRecordId) => { - await deleteProjectRecord(uuid); - await createProjectRecord(uuid, record); -+ -+ if (stagingRecordId) { -+ await Staging.destroy({ -+ where: { -+ id: stagingRecordId, -+ }, -+ }); -+ } - }; - --export const createProjectRecord = (uuid, record) => { -+export const createProjectRecord = (uuid, record, stagingRecordId) => { - return new Promise((resolve) => { - setTimeout(async () => { - await Project.create({ - ...record, - warehouseProjectId: uuid, - }); -+ -+ if (stagingRecordId) { -+ await Staging.destroy({ -+ where: { -+ id: stagingRecordId, -+ }, -+ }); -+ } - resolve(); - }, THIRTY_SEC); - }); - }; - --export const deleteProjectRecord = (uuid) => { -+export const deleteProjectRecord = (uuid, stagingRecordId) => { - return new Promise((resolve) => { - setTimeout(async () => { - await Project.destroy({ -@@ -28,29 +44,53 @@ export const deleteProjectRecord = (uuid) => { - warehouseProjectId: uuid, - }, - }); -+ -+ if (stagingRecordId) { -+ await Staging.destroy({ -+ where: { -+ id: stagingRecordId, -+ }, -+ }); -+ } - resolve(); - }, THIRTY_SEC); - }); - }; - --export const updateUnitRecord = async (uuid, record) => { -+export const updateUnitRecord = async (uuid, record, stagingRecordId) => { - await deleteUnitRecord(uuid); - await createUnitRecord(uuid, record); -+ -+ if (stagingRecordId) { -+ await Staging.destroy({ -+ where: { -+ id: stagingRecordId, -+ }, -+ }); -+ } - }; - --export const createUnitRecord = (uuid, record) => { -+export const createUnitRecord = (uuid, record, stagingRecordId) => { - return new Promise((resolve) => { - setTimeout(async () => { - await Unit.create({ - uuid, - ...record, - }); -+ -+ if (stagingRecordId) { -+ await Staging.destroy({ -+ where: { -+ id: stagingRecordId, -+ }, -+ }); -+ } - resolve(); - }, THIRTY_SEC); - }); - }; - --export const deleteUnitRecord = (uuid) => { -+export const deleteUnitRecord = (uuid, stagingRecordId) => { - return new Promise((resolve) => { - setTimeout(async () => { - await Unit.destroy({ -@@ -58,6 +98,14 @@ export const deleteUnitRecord = (uuid) => { - uuid, - }, - }); -+ -+ if (stagingRecordId) { -+ await Staging.destroy({ -+ where: { -+ id: stagingRecordId, -+ }, -+ }); -+ } - resolve(); - }, THIRTY_SEC); - }); --- -2.34.1.windows.1 -