From 62dc399a1a7ca5d4d5930f1a69273336c4a5fac7 Mon Sep 17 00:00:00 2001 From: Bilal Catic Date: Thu, 9 Jan 2020 23:23:28 +0100 Subject: [PATCH] stop inserting and changing deleted unlock incidents --- routes/index.js | 10 +++++++++- services/integration/doorLockCharges.js | 3 +-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/routes/index.js b/routes/index.js index 699bcde..0581b8a 100644 --- a/routes/index.js +++ b/routes/index.js @@ -46,6 +46,14 @@ router.get('/integration/report/practiceSummary/:year', getPracticeSummaryReport // temporary route, manually trigger door lock charge calculations -router.get('/calculate', (req, res) => { calculateDoorLockCharges().then(() => res.send('Done')).catch((err) => res.send('Error \r\n', err));}); +router.get('/calculate', (req, res) => { + calculateDoorLockCharges() + .then(() => { + res.send('Done'); + }) + .catch((err) => { + res.send(`Error \r\n ${err}`); + }); +}); module.exports = router; diff --git a/services/integration/doorLockCharges.js b/services/integration/doorLockCharges.js index b18d95c..35506f3 100644 --- a/services/integration/doorLockCharges.js +++ b/services/integration/doorLockCharges.js @@ -126,7 +126,6 @@ const insertUnlockedIncidents = (incidents) => { bookingStart: start, bookingEnd: end, unlockTimestamp, - incidentLevel, }, defaults: {...incidentForDB}, })); @@ -198,7 +197,7 @@ const setUnlockedIncidentsLevel = (incidents) => { const incidentsWithLevel = []; incidents.forEach((incident) => { - const memberLastIncident = membersLastIncident[incident.memberId]; + const memberLastIncident = Object.assign({}, membersLastIncident[incident.memberId]); const formattedIncident = { reservation: incident.reservation,