From 1e5003547462df0016f9b123d19c8ae7c3cd7da9 Mon Sep 17 00:00:00 2001 From: Dan Gowans Date: Mon, 27 Mar 2023 12:35:10 -0400 Subject: [PATCH] tidying --- bin/www.js | 2 +- bin/www.ts | 2 +- handlers/lots-post/doCreateLot.js | 2 +- handlers/lots-post/doCreateLot.ts | 2 +- handlers/maps-post/doDeleteMap.js | 2 +- handlers/maps-post/doDeleteMap.ts | 2 +- helpers/functions.lots.ts | 2 ++ helpers/lotOccupancyDB/deleteRecord.ts | 4 ++-- helpers/lotOccupancyDB/updateLot.js | 4 ---- helpers/lotOccupancyDB/updateLot.ts | 7 ------- 10 files changed, 10 insertions(+), 19 deletions(-) diff --git a/bin/www.js b/bin/www.js index 5ddaba3b..5a42ffc1 100644 --- a/bin/www.js +++ b/bin/www.js @@ -29,7 +29,7 @@ cluster.on('message', (worker, message) => { if (worker === undefined || pid === message.pid) { continue; } - debug('Relaying message to workers'); + debug(`Relaying message to worker: ${pid}`); worker.send(message); } }); diff --git a/bin/www.ts b/bin/www.ts index e7d9d6af..a8b3a1f1 100644 --- a/bin/www.ts +++ b/bin/www.ts @@ -50,7 +50,7 @@ cluster.on('message', (worker, message: WorkerMessage) => { continue } - debug('Relaying message to workers') + debug(`Relaying message to worker: ${pid}`) worker.send(message) } }) diff --git a/handlers/lots-post/doCreateLot.js b/handlers/lots-post/doCreateLot.js index 9010eb34..97d8fc38 100644 --- a/handlers/lots-post/doCreateLot.js +++ b/handlers/lots-post/doCreateLot.js @@ -7,7 +7,7 @@ export async function handler(request, response) { lotId }); response.on('finish', () => { - clearNextPreviousLotIdCache(); + clearNextPreviousLotIdCache(-1); }); } export default handler; diff --git a/handlers/lots-post/doCreateLot.ts b/handlers/lots-post/doCreateLot.ts index d643cda0..f269eded 100644 --- a/handlers/lots-post/doCreateLot.ts +++ b/handlers/lots-post/doCreateLot.ts @@ -15,7 +15,7 @@ export async function handler( }) response.on('finish', () => { - clearNextPreviousLotIdCache() + clearNextPreviousLotIdCache(-1) }) } diff --git a/handlers/maps-post/doDeleteMap.js b/handlers/maps-post/doDeleteMap.js index 4edeb594..b2498529 100644 --- a/handlers/maps-post/doDeleteMap.js +++ b/handlers/maps-post/doDeleteMap.js @@ -6,7 +6,7 @@ export async function handler(request, response) { success }); response.on('finish', () => { - clearNextPreviousLotIdCache(); + clearNextPreviousLotIdCache(-1); }); } export default handler; diff --git a/handlers/maps-post/doDeleteMap.ts b/handlers/maps-post/doDeleteMap.ts index 116edc2c..5af19a22 100644 --- a/handlers/maps-post/doDeleteMap.ts +++ b/handlers/maps-post/doDeleteMap.ts @@ -18,7 +18,7 @@ export async function handler( }) response.on('finish', () => { - clearNextPreviousLotIdCache() + clearNextPreviousLotIdCache(-1) }) } diff --git a/helpers/functions.lots.ts b/helpers/functions.lots.ts index 9ab4d972..e43fe688 100644 --- a/helpers/functions.lots.ts +++ b/helpers/functions.lots.ts @@ -1,3 +1,5 @@ +/* eslint-disable @typescript-eslint/indent */ + import cluster from 'node:cluster' import NodeCache from 'node-cache' diff --git a/helpers/lotOccupancyDB/deleteRecord.ts b/helpers/lotOccupancyDB/deleteRecord.ts index 6392dd26..a19ea159 100644 --- a/helpers/lotOccupancyDB/deleteRecord.ts +++ b/helpers/lotOccupancyDB/deleteRecord.ts @@ -24,7 +24,7 @@ type RecordTable = | 'WorkOrderMilestoneTypes' | 'WorkOrderTypes' -const recordIdColumns: Map = new Map() +const recordIdColumns = new Map() recordIdColumns.set('FeeCategories', 'feeCategoryId') recordIdColumns.set('Fees', 'feeId') recordIdColumns.set('Lots', 'lotId') @@ -44,7 +44,7 @@ recordIdColumns.set('WorkOrderMilestones', 'workOrderMilestoneId') recordIdColumns.set('WorkOrderMilestoneTypes', 'workOrderMilestoneTypeId') recordIdColumns.set('WorkOrderTypes', 'workOrderTypeId') -const relatedTables: Map = new Map() +const relatedTables = new Map() relatedTables.set('FeeCategories', ['Fees']) relatedTables.set('Lots', ['LotFields', 'LotComments']) relatedTables.set('LotOccupancies', [ diff --git a/helpers/lotOccupancyDB/updateLot.js b/helpers/lotOccupancyDB/updateLot.js index c6998c95..b73497cd 100644 --- a/helpers/lotOccupancyDB/updateLot.js +++ b/helpers/lotOccupancyDB/updateLot.js @@ -1,7 +1,6 @@ import { acquireConnection } from './pool.js'; import { addOrUpdateLotField } from './addOrUpdateLotField.js'; import { deleteLotField } from './deleteLotField.js'; -import { clearNextPreviousLotIdCache } from '../functions.lots.js'; export async function updateLot(lotForm, requestSession) { const database = await acquireConnection(); const rightNowMillis = Date.now(); @@ -33,9 +32,6 @@ export async function updateLot(lotForm, requestSession) { } } database.release(); - clearNextPreviousLotIdCache(typeof lotForm.lotId === 'number' - ? lotForm.lotId - : Number.parseInt(lotForm.lotId, 10)); return result.changes > 0; } export async function updateLotStatus(lotId, lotStatusId, requestSession) { diff --git a/helpers/lotOccupancyDB/updateLot.ts b/helpers/lotOccupancyDB/updateLot.ts index ce9b2354..15daa98a 100644 --- a/helpers/lotOccupancyDB/updateLot.ts +++ b/helpers/lotOccupancyDB/updateLot.ts @@ -5,7 +5,6 @@ import { addOrUpdateLotField } from './addOrUpdateLotField.js' import { deleteLotField } from './deleteLotField.js' import type * as recordTypes from '../../types/recordTypes' -import { clearNextPreviousLotIdCache } from '../functions.lots.js' interface UpdateLotForm { lotId: string | number @@ -88,12 +87,6 @@ export async function updateLot( database.release() - clearNextPreviousLotIdCache( - typeof lotForm.lotId === 'number' - ? lotForm.lotId - : Number.parseInt(lotForm.lotId, 10) - ) - return result.changes > 0 }