From 3eb4958f6574d764db339c2e8b80e4bda87e4324 Mon Sep 17 00:00:00 2001 From: Dan Gowans Date: Tue, 17 Jan 2023 13:26:38 -0500 Subject: [PATCH] linting --- helpers/lotOccupancyDB/addRecord.js | 3 +- helpers/lotOccupancyDB/addRecord.ts | 3 +- helpers/lotOccupancyDB/addWorkOrderComment.js | 12 +++---- helpers/lotOccupancyDB/addWorkOrderComment.ts | 12 +++---- helpers/lotOccupancyDB/addWorkOrderLot.js | 8 ++--- helpers/lotOccupancyDB/addWorkOrderLot.ts | 8 ++--- helpers/lotOccupancyDB/copyLotOccupancy.js | 8 ++--- helpers/lotOccupancyDB/copyLotOccupancy.ts | 8 ++--- helpers/lotOccupancyDB/deleteRecord.js | 16 ++++----- helpers/lotOccupancyDB/deleteRecord.ts | 16 ++++----- helpers/lotOccupancyDB/getLotOccupancies.js | 24 ++++++------- helpers/lotOccupancyDB/getLotOccupancies.ts | 24 ++++++------- .../lotOccupancyDB/getLotOccupancyComments.js | 16 ++++----- .../lotOccupancyDB/getLotOccupancyComments.ts | 16 ++++----- .../getLotOccupancyOccupants.js | 24 ++++++------- .../getLotOccupancyOccupants.ts | 24 ++++++------- .../getLotOccupancyTransactions.js | 14 ++++---- .../getLotOccupancyTransactions.ts | 14 ++++---- helpers/lotOccupancyDB/getLots.js | 34 ++++++++----------- helpers/lotOccupancyDB/getLots.ts | 34 ++++++++----------- helpers/lotOccupancyDB/getMaps.js | 6 ++-- helpers/lotOccupancyDB/getMaps.ts | 6 ++-- temp/legacy.importFromCSV.js | 2 ++ temp/legacy.importFromCSV.ts | 2 ++ 24 files changed, 166 insertions(+), 168 deletions(-) diff --git a/helpers/lotOccupancyDB/addRecord.js b/helpers/lotOccupancyDB/addRecord.js index a26e397b..bc60252e 100644 --- a/helpers/lotOccupancyDB/addRecord.js +++ b/helpers/lotOccupancyDB/addRecord.js @@ -13,7 +13,8 @@ export function addRecord(recordTable, recordName, orderNumber, requestSession) const rightNowMillis = Date.now(); const result = database .prepare(`insert into ${recordTable} ( - ${recordNameColumns.get(recordTable)}, orderNumber, + ${recordNameColumns.get(recordTable)}, + orderNumber, recordCreate_userName, recordCreate_timeMillis, recordUpdate_userName, recordUpdate_timeMillis) values (?, ?, ?, ?, ?, ?)`) diff --git a/helpers/lotOccupancyDB/addRecord.ts b/helpers/lotOccupancyDB/addRecord.ts index 06301cd6..3606ea52 100644 --- a/helpers/lotOccupancyDB/addRecord.ts +++ b/helpers/lotOccupancyDB/addRecord.ts @@ -34,7 +34,8 @@ export function addRecord( const result = database .prepare( `insert into ${recordTable} ( - ${recordNameColumns.get(recordTable)!}, orderNumber, + ${recordNameColumns.get(recordTable)!}, + orderNumber, recordCreate_userName, recordCreate_timeMillis, recordUpdate_userName, recordUpdate_timeMillis) values (?, ?, ?, ?, ?, ?)` diff --git a/helpers/lotOccupancyDB/addWorkOrderComment.js b/helpers/lotOccupancyDB/addWorkOrderComment.js index c32338d6..e8c91f28 100644 --- a/helpers/lotOccupancyDB/addWorkOrderComment.js +++ b/helpers/lotOccupancyDB/addWorkOrderComment.js @@ -6,12 +6,12 @@ export function addWorkOrderComment(workOrderCommentForm, requestSession) { const rightNow = new Date(); const result = database .prepare(`insert into WorkOrderComments ( - workOrderId, - workOrderCommentDate, workOrderCommentTime, - workOrderComment, - recordCreate_userName, recordCreate_timeMillis, - recordUpdate_userName, recordUpdate_timeMillis) - values (?, ?, ?, ?, ?, ?, ?, ?)`) + workOrderId, + workOrderCommentDate, workOrderCommentTime, + workOrderComment, + recordCreate_userName, recordCreate_timeMillis, + recordUpdate_userName, recordUpdate_timeMillis) + values (?, ?, ?, ?, ?, ?, ?, ?)`) .run(workOrderCommentForm.workOrderId, dateTimeFunctions.dateToInteger(rightNow), dateTimeFunctions.dateToTimeInteger(rightNow), workOrderCommentForm.workOrderComment, requestSession.user.userName, rightNow.getTime(), requestSession.user.userName, rightNow.getTime()); database.close(); return result.lastInsertRowid; diff --git a/helpers/lotOccupancyDB/addWorkOrderComment.ts b/helpers/lotOccupancyDB/addWorkOrderComment.ts index 32d34f39..96d5cdc0 100644 --- a/helpers/lotOccupancyDB/addWorkOrderComment.ts +++ b/helpers/lotOccupancyDB/addWorkOrderComment.ts @@ -22,12 +22,12 @@ export function addWorkOrderComment( const result = database .prepare( `insert into WorkOrderComments ( - workOrderId, - workOrderCommentDate, workOrderCommentTime, - workOrderComment, - recordCreate_userName, recordCreate_timeMillis, - recordUpdate_userName, recordUpdate_timeMillis) - values (?, ?, ?, ?, ?, ?, ?, ?)` + workOrderId, + workOrderCommentDate, workOrderCommentTime, + workOrderComment, + recordCreate_userName, recordCreate_timeMillis, + recordUpdate_userName, recordUpdate_timeMillis) + values (?, ?, ?, ?, ?, ?, ?, ?)` ) .run( workOrderCommentForm.workOrderId, diff --git a/helpers/lotOccupancyDB/addWorkOrderLot.js b/helpers/lotOccupancyDB/addWorkOrderLot.js index 341ed7ac..1fa7d893 100644 --- a/helpers/lotOccupancyDB/addWorkOrderLot.js +++ b/helpers/lotOccupancyDB/addWorkOrderLot.js @@ -27,10 +27,10 @@ export function addWorkOrderLot(workOrderLotForm, requestSession) { else { database .prepare(`insert into WorkOrderLots ( - workOrderId, lotId, - recordCreate_userName, recordCreate_timeMillis, - recordUpdate_userName, recordUpdate_timeMillis) - values (?, ?, ?, ?, ?, ?)`) + workOrderId, lotId, + recordCreate_userName, recordCreate_timeMillis, + recordUpdate_userName, recordUpdate_timeMillis) + values (?, ?, ?, ?, ?, ?)`) .run(workOrderLotForm.workOrderId, workOrderLotForm.lotId, requestSession.user.userName, rightNowMillis, requestSession.user.userName, rightNowMillis); } database.close(); diff --git a/helpers/lotOccupancyDB/addWorkOrderLot.ts b/helpers/lotOccupancyDB/addWorkOrderLot.ts index 76fe58df..8cfcaf12 100644 --- a/helpers/lotOccupancyDB/addWorkOrderLot.ts +++ b/helpers/lotOccupancyDB/addWorkOrderLot.ts @@ -53,10 +53,10 @@ export function addWorkOrderLot( database .prepare( `insert into WorkOrderLots ( - workOrderId, lotId, - recordCreate_userName, recordCreate_timeMillis, - recordUpdate_userName, recordUpdate_timeMillis) - values (?, ?, ?, ?, ?, ?)` + workOrderId, lotId, + recordCreate_userName, recordCreate_timeMillis, + recordUpdate_userName, recordUpdate_timeMillis) + values (?, ?, ?, ?, ?, ?)` ) .run( workOrderLotForm.workOrderId, diff --git a/helpers/lotOccupancyDB/copyLotOccupancy.js b/helpers/lotOccupancyDB/copyLotOccupancy.js index 4074d291..2ef6cee9 100644 --- a/helpers/lotOccupancyDB/copyLotOccupancy.js +++ b/helpers/lotOccupancyDB/copyLotOccupancy.js @@ -17,10 +17,10 @@ export function copyLotOccupancy(oldLotOccupancyId, requestSession) { for (const occupancyField of oldLotOccupancy.lotOccupancyFields ?? []) { database .prepare(`insert into LotOccupancyFields ( - lotOccupancyId, occupancyTypeFieldId, lotOccupancyFieldValue, - recordCreate_userName, recordCreate_timeMillis, - recordUpdate_userName, recordUpdate_timeMillis) - values (?, ?, ?, ?, ?, ?, ?)`) + lotOccupancyId, occupancyTypeFieldId, lotOccupancyFieldValue, + recordCreate_userName, recordCreate_timeMillis, + recordUpdate_userName, recordUpdate_timeMillis) + values (?, ?, ?, ?, ?, ?, ?)`) .run(newLotOccupancyId, occupancyField.occupancyTypeFieldId, occupancyField.lotOccupancyFieldValue, requestSession.user.userName, rightNowMillis, requestSession.user.userName, rightNowMillis); } for (const occupant of oldLotOccupancy.lotOccupancyOccupants ?? []) { diff --git a/helpers/lotOccupancyDB/copyLotOccupancy.ts b/helpers/lotOccupancyDB/copyLotOccupancy.ts index 85ff2810..9fe9c084 100644 --- a/helpers/lotOccupancyDB/copyLotOccupancy.ts +++ b/helpers/lotOccupancyDB/copyLotOccupancy.ts @@ -39,10 +39,10 @@ export function copyLotOccupancy( database .prepare( `insert into LotOccupancyFields ( - lotOccupancyId, occupancyTypeFieldId, lotOccupancyFieldValue, - recordCreate_userName, recordCreate_timeMillis, - recordUpdate_userName, recordUpdate_timeMillis) - values (?, ?, ?, ?, ?, ?, ?)` + lotOccupancyId, occupancyTypeFieldId, lotOccupancyFieldValue, + recordCreate_userName, recordCreate_timeMillis, + recordUpdate_userName, recordUpdate_timeMillis) + values (?, ?, ?, ?, ?, ?, ?)` ) .run( newLotOccupancyId, diff --git a/helpers/lotOccupancyDB/deleteRecord.js b/helpers/lotOccupancyDB/deleteRecord.js index f2c9be8d..18378cb7 100644 --- a/helpers/lotOccupancyDB/deleteRecord.js +++ b/helpers/lotOccupancyDB/deleteRecord.js @@ -45,18 +45,18 @@ export function deleteRecord(recordTable, recordId, requestSession) { const rightNowMillis = Date.now(); const result = database .prepare(`update ${recordTable} - set recordDelete_userName = ?, - recordDelete_timeMillis = ? - where ${recordIdColumns.get(recordTable)} = ? - and recordDelete_timeMillis is null`) + set recordDelete_userName = ?, + recordDelete_timeMillis = ? + where ${recordIdColumns.get(recordTable)} = ? + and recordDelete_timeMillis is null`) .run(requestSession.user.userName, rightNowMillis, recordId); for (const relatedTable of relatedTables.get(recordTable) ?? []) { database .prepare(`update ${relatedTable} - set recordDelete_userName = ?, - recordDelete_timeMillis = ? - where ${recordIdColumns.get(recordTable)} = ? - and recordDelete_timeMillis is null`) + set recordDelete_userName = ?, + recordDelete_timeMillis = ? + where ${recordIdColumns.get(recordTable)} = ? + and recordDelete_timeMillis is null`) .run(requestSession.user.userName, rightNowMillis, recordId); } database.close(); diff --git a/helpers/lotOccupancyDB/deleteRecord.ts b/helpers/lotOccupancyDB/deleteRecord.ts index 05531f7f..646d1cd0 100644 --- a/helpers/lotOccupancyDB/deleteRecord.ts +++ b/helpers/lotOccupancyDB/deleteRecord.ts @@ -79,10 +79,10 @@ export function deleteRecord( const result = database .prepare( `update ${recordTable} - set recordDelete_userName = ?, - recordDelete_timeMillis = ? - where ${recordIdColumns.get(recordTable)!} = ? - and recordDelete_timeMillis is null` + set recordDelete_userName = ?, + recordDelete_timeMillis = ? + where ${recordIdColumns.get(recordTable)!} = ? + and recordDelete_timeMillis is null` ) .run(requestSession.user!.userName, rightNowMillis, recordId) @@ -90,10 +90,10 @@ export function deleteRecord( database .prepare( `update ${relatedTable} - set recordDelete_userName = ?, - recordDelete_timeMillis = ? - where ${recordIdColumns.get(recordTable)!} = ? - and recordDelete_timeMillis is null` + set recordDelete_userName = ?, + recordDelete_timeMillis = ? + where ${recordIdColumns.get(recordTable)!} = ? + and recordDelete_timeMillis is null` ) .run(requestSession.user!.userName, rightNowMillis, recordId) } diff --git a/helpers/lotOccupancyDB/getLotOccupancies.js b/helpers/lotOccupancyDB/getLotOccupancies.js index 7dafdc65..e3ee9e96 100644 --- a/helpers/lotOccupancyDB/getLotOccupancies.js +++ b/helpers/lotOccupancyDB/getLotOccupancies.js @@ -83,18 +83,18 @@ export function getLotOccupancies(filters, options, connectedDatabase) { if (count !== 0) { lotOccupancies = database .prepare(`select o.lotOccupancyId, - o.occupancyTypeId, t.occupancyType, - o.lotId, lt.lotType, l.lotName, - l.mapId, m.mapName, - o.occupancyStartDate, userFn_dateIntegerToString(o.occupancyStartDate) as occupancyStartDateString, - o.occupancyEndDate, userFn_dateIntegerToString(o.occupancyEndDate) as occupancyEndDateString - from LotOccupancies o - left join OccupancyTypes t on o.occupancyTypeId = t.occupancyTypeId - left join Lots l on o.lotId = l.lotId - left join LotTypes lt on l.lotTypeId = lt.lotTypeId - left join Maps m on l.mapId = m.mapId - ${sqlWhereClause} - order by o.occupancyStartDate desc, ifnull(o.occupancyEndDate, 99999999) desc, l.lotName, o.lotId, o.lotOccupancyId desc` + + o.occupancyTypeId, t.occupancyType, + o.lotId, lt.lotType, l.lotName, + l.mapId, m.mapName, + o.occupancyStartDate, userFn_dateIntegerToString(o.occupancyStartDate) as occupancyStartDateString, + o.occupancyEndDate, userFn_dateIntegerToString(o.occupancyEndDate) as occupancyEndDateString + from LotOccupancies o + left join OccupancyTypes t on o.occupancyTypeId = t.occupancyTypeId + left join Lots l on o.lotId = l.lotId + left join LotTypes lt on l.lotTypeId = lt.lotTypeId + left join Maps m on l.mapId = m.mapId + ${sqlWhereClause} + order by o.occupancyStartDate desc, ifnull(o.occupancyEndDate, 99999999) desc, l.lotName, o.lotId, o.lotOccupancyId desc` + (isLimited ? ` limit ${options.limit} offset ${options.offset}` : '')) .all(sqlParameters); if (!isLimited) { diff --git a/helpers/lotOccupancyDB/getLotOccupancies.ts b/helpers/lotOccupancyDB/getLotOccupancies.ts index e64554cd..8e410493 100644 --- a/helpers/lotOccupancyDB/getLotOccupancies.ts +++ b/helpers/lotOccupancyDB/getLotOccupancies.ts @@ -167,18 +167,18 @@ export function getLotOccupancies( lotOccupancies = database .prepare( `select o.lotOccupancyId, - o.occupancyTypeId, t.occupancyType, - o.lotId, lt.lotType, l.lotName, - l.mapId, m.mapName, - o.occupancyStartDate, userFn_dateIntegerToString(o.occupancyStartDate) as occupancyStartDateString, - o.occupancyEndDate, userFn_dateIntegerToString(o.occupancyEndDate) as occupancyEndDateString - from LotOccupancies o - left join OccupancyTypes t on o.occupancyTypeId = t.occupancyTypeId - left join Lots l on o.lotId = l.lotId - left join LotTypes lt on l.lotTypeId = lt.lotTypeId - left join Maps m on l.mapId = m.mapId - ${sqlWhereClause} - order by o.occupancyStartDate desc, ifnull(o.occupancyEndDate, 99999999) desc, l.lotName, o.lotId, o.lotOccupancyId desc` + + o.occupancyTypeId, t.occupancyType, + o.lotId, lt.lotType, l.lotName, + l.mapId, m.mapName, + o.occupancyStartDate, userFn_dateIntegerToString(o.occupancyStartDate) as occupancyStartDateString, + o.occupancyEndDate, userFn_dateIntegerToString(o.occupancyEndDate) as occupancyEndDateString + from LotOccupancies o + left join OccupancyTypes t on o.occupancyTypeId = t.occupancyTypeId + left join Lots l on o.lotId = l.lotId + left join LotTypes lt on l.lotTypeId = lt.lotTypeId + left join Maps m on l.mapId = m.mapId + ${sqlWhereClause} + order by o.occupancyStartDate desc, ifnull(o.occupancyEndDate, 99999999) desc, l.lotName, o.lotId, o.lotOccupancyId desc` + (isLimited ? ` limit ${options.limit} offset ${options.offset}` : '') ) .all(sqlParameters) diff --git a/helpers/lotOccupancyDB/getLotOccupancyComments.js b/helpers/lotOccupancyDB/getLotOccupancyComments.js index 39e8b2a1..8cd1b00f 100644 --- a/helpers/lotOccupancyDB/getLotOccupancyComments.js +++ b/helpers/lotOccupancyDB/getLotOccupancyComments.js @@ -10,14 +10,14 @@ export function getLotOccupancyComments(lotOccupancyId, connectedDatabase) { database.function('userFn_timeIntegerToString', timeIntegerToString); const lotComments = database .prepare(`select lotOccupancyCommentId, - lotOccupancyCommentDate, userFn_dateIntegerToString(lotOccupancyCommentDate) as lotOccupancyCommentDateString, - lotOccupancyCommentTime, userFn_timeIntegerToString(lotOccupancyCommentTime) as lotOccupancyCommentTimeString, - lotOccupancyComment, - recordCreate_userName, recordUpdate_userName - from LotOccupancyComments - where recordDelete_timeMillis is null - and lotOccupancyId = ? - order by lotOccupancyCommentDate desc, lotOccupancyCommentTime desc, lotOccupancyCommentId desc`) + lotOccupancyCommentDate, userFn_dateIntegerToString(lotOccupancyCommentDate) as lotOccupancyCommentDateString, + lotOccupancyCommentTime, userFn_timeIntegerToString(lotOccupancyCommentTime) as lotOccupancyCommentTimeString, + lotOccupancyComment, + recordCreate_userName, recordUpdate_userName + from LotOccupancyComments + where recordDelete_timeMillis is null + and lotOccupancyId = ? + order by lotOccupancyCommentDate desc, lotOccupancyCommentTime desc, lotOccupancyCommentId desc`) .all(lotOccupancyId); if (!connectedDatabase) { database.close(); diff --git a/helpers/lotOccupancyDB/getLotOccupancyComments.ts b/helpers/lotOccupancyDB/getLotOccupancyComments.ts index 2419f95b..016bebb0 100644 --- a/helpers/lotOccupancyDB/getLotOccupancyComments.ts +++ b/helpers/lotOccupancyDB/getLotOccupancyComments.ts @@ -25,14 +25,14 @@ export function getLotOccupancyComments( const lotComments = database .prepare( `select lotOccupancyCommentId, - lotOccupancyCommentDate, userFn_dateIntegerToString(lotOccupancyCommentDate) as lotOccupancyCommentDateString, - lotOccupancyCommentTime, userFn_timeIntegerToString(lotOccupancyCommentTime) as lotOccupancyCommentTimeString, - lotOccupancyComment, - recordCreate_userName, recordUpdate_userName - from LotOccupancyComments - where recordDelete_timeMillis is null - and lotOccupancyId = ? - order by lotOccupancyCommentDate desc, lotOccupancyCommentTime desc, lotOccupancyCommentId desc` + lotOccupancyCommentDate, userFn_dateIntegerToString(lotOccupancyCommentDate) as lotOccupancyCommentDateString, + lotOccupancyCommentTime, userFn_timeIntegerToString(lotOccupancyCommentTime) as lotOccupancyCommentTimeString, + lotOccupancyComment, + recordCreate_userName, recordUpdate_userName + from LotOccupancyComments + where recordDelete_timeMillis is null + and lotOccupancyId = ? + order by lotOccupancyCommentDate desc, lotOccupancyCommentTime desc, lotOccupancyCommentId desc` ) .all(lotOccupancyId) diff --git a/helpers/lotOccupancyDB/getLotOccupancyOccupants.js b/helpers/lotOccupancyDB/getLotOccupancyOccupants.js index 18df6656..37d8cc65 100644 --- a/helpers/lotOccupancyDB/getLotOccupancyOccupants.js +++ b/helpers/lotOccupancyDB/getLotOccupancyOccupants.js @@ -7,18 +7,18 @@ export function getLotOccupancyOccupants(lotOccupancyId, connectedDatabase) { }); const lotOccupancyOccupants = database .prepare(`select o.lotOccupancyId, o.lotOccupantIndex, - o.occupantName, - o.occupantAddress1, o.occupantAddress2, - o.occupantCity, o.occupantProvince, o.occupantPostalCode, - o.occupantPhoneNumber, o.occupantEmailAddress, - o.occupantComment, - o.lotOccupantTypeId, t.lotOccupantType, - t.fontAwesomeIconClass - from LotOccupancyOccupants o - left join LotOccupantTypes t on o.lotOccupantTypeId = t.lotOccupantTypeId - where o.recordDelete_timeMillis is null - and o.lotOccupancyId = ? - order by t.orderNumber, t.lotOccupantType, o.occupantName, o.lotOccupantIndex`) + o.occupantName, + o.occupantAddress1, o.occupantAddress2, + o.occupantCity, o.occupantProvince, o.occupantPostalCode, + o.occupantPhoneNumber, o.occupantEmailAddress, + o.occupantComment, + o.lotOccupantTypeId, t.lotOccupantType, + t.fontAwesomeIconClass + from LotOccupancyOccupants o + left join LotOccupantTypes t on o.lotOccupantTypeId = t.lotOccupantTypeId + where o.recordDelete_timeMillis is null + and o.lotOccupancyId = ? + order by t.orderNumber, t.lotOccupantType, o.occupantName, o.lotOccupantIndex`) .all(lotOccupancyId); if (!connectedDatabase) { database.close(); diff --git a/helpers/lotOccupancyDB/getLotOccupancyOccupants.ts b/helpers/lotOccupancyDB/getLotOccupancyOccupants.ts index 60e8d2de..fce68f4e 100644 --- a/helpers/lotOccupancyDB/getLotOccupancyOccupants.ts +++ b/helpers/lotOccupancyDB/getLotOccupancyOccupants.ts @@ -17,18 +17,18 @@ export function getLotOccupancyOccupants( const lotOccupancyOccupants: recordTypes.LotOccupancyOccupant[] = database .prepare( `select o.lotOccupancyId, o.lotOccupantIndex, - o.occupantName, - o.occupantAddress1, o.occupantAddress2, - o.occupantCity, o.occupantProvince, o.occupantPostalCode, - o.occupantPhoneNumber, o.occupantEmailAddress, - o.occupantComment, - o.lotOccupantTypeId, t.lotOccupantType, - t.fontAwesomeIconClass - from LotOccupancyOccupants o - left join LotOccupantTypes t on o.lotOccupantTypeId = t.lotOccupantTypeId - where o.recordDelete_timeMillis is null - and o.lotOccupancyId = ? - order by t.orderNumber, t.lotOccupantType, o.occupantName, o.lotOccupantIndex` + o.occupantName, + o.occupantAddress1, o.occupantAddress2, + o.occupantCity, o.occupantProvince, o.occupantPostalCode, + o.occupantPhoneNumber, o.occupantEmailAddress, + o.occupantComment, + o.lotOccupantTypeId, t.lotOccupantType, + t.fontAwesomeIconClass + from LotOccupancyOccupants o + left join LotOccupantTypes t on o.lotOccupantTypeId = t.lotOccupantTypeId + where o.recordDelete_timeMillis is null + and o.lotOccupancyId = ? + order by t.orderNumber, t.lotOccupantType, o.occupantName, o.lotOccupantIndex` ) .all(lotOccupancyId) diff --git a/helpers/lotOccupancyDB/getLotOccupancyTransactions.js b/helpers/lotOccupancyDB/getLotOccupancyTransactions.js index 7df89029..a28923b2 100644 --- a/helpers/lotOccupancyDB/getLotOccupancyTransactions.js +++ b/helpers/lotOccupancyDB/getLotOccupancyTransactions.js @@ -10,13 +10,13 @@ export function getLotOccupancyTransactions(lotOccupancyId, connectedDatabase) { database.function('userFn_timeIntegerToString', timeIntegerToString); const lotOccupancyTransactions = database .prepare(`select lotOccupancyId, transactionIndex, - transactionDate, userFn_dateIntegerToString(transactionDate) as transactionDateString, - transactionTime, userFn_timeIntegerToString(transactionTime) as transactionTimeString, - transactionAmount, externalReceiptNumber, transactionNote - from LotOccupancyTransactions - where recordDelete_timeMillis is null - and lotOccupancyId = ? - order by transactionDate, transactionTime, transactionIndex`) + transactionDate, userFn_dateIntegerToString(transactionDate) as transactionDateString, + transactionTime, userFn_timeIntegerToString(transactionTime) as transactionTimeString, + transactionAmount, externalReceiptNumber, transactionNote + from LotOccupancyTransactions + where recordDelete_timeMillis is null + and lotOccupancyId = ? + order by transactionDate, transactionTime, transactionIndex`) .all(lotOccupancyId); if (!connectedDatabase) { database.close(); diff --git a/helpers/lotOccupancyDB/getLotOccupancyTransactions.ts b/helpers/lotOccupancyDB/getLotOccupancyTransactions.ts index 7765bd6b..8bbc32c8 100644 --- a/helpers/lotOccupancyDB/getLotOccupancyTransactions.ts +++ b/helpers/lotOccupancyDB/getLotOccupancyTransactions.ts @@ -26,13 +26,13 @@ export function getLotOccupancyTransactions( database .prepare( `select lotOccupancyId, transactionIndex, - transactionDate, userFn_dateIntegerToString(transactionDate) as transactionDateString, - transactionTime, userFn_timeIntegerToString(transactionTime) as transactionTimeString, - transactionAmount, externalReceiptNumber, transactionNote - from LotOccupancyTransactions - where recordDelete_timeMillis is null - and lotOccupancyId = ? - order by transactionDate, transactionTime, transactionIndex` + transactionDate, userFn_dateIntegerToString(transactionDate) as transactionDateString, + transactionTime, userFn_timeIntegerToString(transactionTime) as transactionTimeString, + transactionAmount, externalReceiptNumber, transactionNote + from LotOccupancyTransactions + where recordDelete_timeMillis is null + and lotOccupancyId = ? + order by transactionDate, transactionTime, transactionIndex` ) .all(lotOccupancyId) diff --git a/helpers/lotOccupancyDB/getLots.js b/helpers/lotOccupancyDB/getLots.js index 521822aa..1af27e66 100644 --- a/helpers/lotOccupancyDB/getLots.js +++ b/helpers/lotOccupancyDB/getLots.js @@ -9,19 +9,19 @@ function buildWhereClause(filters) { const lotNameFilters = getLotNameWhereClause(filters.lotName, filters.lotNameSearchType ?? '', 'l'); sqlWhereClause += lotNameFilters.sqlWhereClause; sqlParameters.push(...lotNameFilters.sqlParameters); - if (filters.mapId) { + if ((filters.mapId ?? '') !== '') { sqlWhereClause += ' and l.mapId = ?'; sqlParameters.push(filters.mapId); } - if (filters.lotTypeId) { + if ((filters.lotTypeId ?? '') !== '') { sqlWhereClause += ' and l.lotTypeId = ?'; sqlParameters.push(filters.lotTypeId); } - if (filters.lotStatusId) { + if ((filters.lotStatusId ?? '') !== '') { sqlWhereClause += ' and l.lotStatusId = ?'; sqlParameters.push(filters.lotStatusId); } - if (filters.occupancyStatus) { + if ((filters.occupancyStatus ?? '') !== '') { if (filters.occupancyStatus === 'occupied') { sqlWhereClause += ' and lotOccupancyCount > 0'; } @@ -30,7 +30,7 @@ function buildWhereClause(filters) { ' and (lotOccupancyCount is null or lotOccupancyCount = 0)'; } } - if (filters.workOrderId) { + if ((filters.workOrderId ?? '') !== '') { sqlWhereClause += ' and l.lotId in (select lotId from WorkOrderLots where recordDelete_timeMillis is null and workOrderId = ?)'; sqlParameters.push(filters.workOrderId); @@ -50,20 +50,16 @@ export function getLots(filters, options, connectedDatabase) { let count = 0; if (options.limit !== -1) { count = database - .prepare('select count(*) as recordCount' + - ' from Lots l' + - (' left join (' + - 'select lotId, count(lotOccupancyId) as lotOccupancyCount' + - ' from LotOccupancies' + - ' where recordDelete_timeMillis is null' + - ' and occupancyStartDate <= ' + - currentDate + - ' and (occupancyEndDate is null or occupancyEndDate >= ' + - currentDate + - ')' + - ' group by lotId' + - ') o on l.lotId = o.lotId') + - sqlWhereClause) + .prepare(`select count(*) as recordCount + from Lots l + left join ( + select lotId, count(lotOccupancyId) as lotOccupancyCount from LotOccupancies + where recordDelete_timeMillis is null + and occupancyStartDate <= ${currentDate} + and (occupancyEndDate is null or occupancyEndDate >= ${currentDate}) + group by lotId + ) o on l.lotId = o.lotId + ${sqlWhereClause}`) .get(sqlParameters).recordCount; } let lots = []; diff --git a/helpers/lotOccupancyDB/getLots.ts b/helpers/lotOccupancyDB/getLots.ts index c2a2e1e9..85b68304 100644 --- a/helpers/lotOccupancyDB/getLots.ts +++ b/helpers/lotOccupancyDB/getLots.ts @@ -41,22 +41,22 @@ function buildWhereClause(filters: GetLotsFilters): { sqlWhereClause += lotNameFilters.sqlWhereClause sqlParameters.push(...lotNameFilters.sqlParameters) - if (filters.mapId) { + if ((filters.mapId ?? '') !== '') { sqlWhereClause += ' and l.mapId = ?' sqlParameters.push(filters.mapId) } - if (filters.lotTypeId) { + if ((filters.lotTypeId ?? '') !== '') { sqlWhereClause += ' and l.lotTypeId = ?' sqlParameters.push(filters.lotTypeId) } - if (filters.lotStatusId) { + if ((filters.lotStatusId ?? '') !== '') { sqlWhereClause += ' and l.lotStatusId = ?' sqlParameters.push(filters.lotStatusId) } - if (filters.occupancyStatus) { + if ((filters.occupancyStatus ?? '') !== '') { if (filters.occupancyStatus === 'occupied') { sqlWhereClause += ' and lotOccupancyCount > 0' } else if (filters.occupancyStatus === 'unoccupied') { @@ -65,7 +65,7 @@ function buildWhereClause(filters: GetLotsFilters): { } } - if (filters.workOrderId) { + if ((filters.workOrderId ?? '') !== '') { sqlWhereClause += ' and l.lotId in (select lotId from WorkOrderLots where recordDelete_timeMillis is null and workOrderId = ?)' sqlParameters.push(filters.workOrderId) @@ -100,20 +100,16 @@ export function getLots( if (options.limit !== -1) { count = database .prepare( - 'select count(*) as recordCount' + - ' from Lots l' + - (' left join (' + - 'select lotId, count(lotOccupancyId) as lotOccupancyCount' + - ' from LotOccupancies' + - ' where recordDelete_timeMillis is null' + - ' and occupancyStartDate <= ' + - currentDate + - ' and (occupancyEndDate is null or occupancyEndDate >= ' + - currentDate + - ')' + - ' group by lotId' + - ') o on l.lotId = o.lotId') + - sqlWhereClause + `select count(*) as recordCount + from Lots l + left join ( + select lotId, count(lotOccupancyId) as lotOccupancyCount from LotOccupancies + where recordDelete_timeMillis is null + and occupancyStartDate <= ${currentDate} + and (occupancyEndDate is null or occupancyEndDate >= ${currentDate}) + group by lotId + ) o on l.lotId = o.lotId + ${sqlWhereClause}` ) .get(sqlParameters).recordCount } diff --git a/helpers/lotOccupancyDB/getMaps.js b/helpers/lotOccupancyDB/getMaps.js index 18b2a8b2..4fa2b5d9 100644 --- a/helpers/lotOccupancyDB/getMaps.js +++ b/helpers/lotOccupancyDB/getMaps.js @@ -12,9 +12,9 @@ export function getMaps() { ifnull(l.lotCount,0) as lotCount from Maps m left join ( - select mapId, count(lotId) as lotCount - from Lots - where recordDelete_timeMillis is null group by mapId + select mapId, count(lotId) as lotCount + from Lots + where recordDelete_timeMillis is null group by mapId ) l on m.mapId = l.mapId where m.recordDelete_timeMillis is null order by m.mapName, m.mapId`) .all(); diff --git a/helpers/lotOccupancyDB/getMaps.ts b/helpers/lotOccupancyDB/getMaps.ts index afb10f4f..a1a4f6cf 100644 --- a/helpers/lotOccupancyDB/getMaps.ts +++ b/helpers/lotOccupancyDB/getMaps.ts @@ -18,9 +18,9 @@ export function getMaps(): recordTypes.Map[] { ifnull(l.lotCount,0) as lotCount from Maps m left join ( - select mapId, count(lotId) as lotCount - from Lots - where recordDelete_timeMillis is null group by mapId + select mapId, count(lotId) as lotCount + from Lots + where recordDelete_timeMillis is null group by mapId ) l on m.mapId = l.mapId where m.recordDelete_timeMillis is null order by m.mapName, m.mapId` ) diff --git a/temp/legacy.importFromCSV.js b/temp/legacy.importFromCSV.js index f129c625..667c83d1 100644 --- a/temp/legacy.importFromCSV.js +++ b/temp/legacy.importFromCSV.js @@ -940,9 +940,11 @@ function importFromWorkOrderCSV() { } console.timeEnd('importFromWorkOrderCSV'); } +console.log('Started ' + (new Date().toLocaleString())); console.time('importFromCsv'); purgeTables(); importFromMasterCSV(); importFromPrepaidCSV(); importFromWorkOrderCSV(); console.timeEnd('importFromCsv'); +console.log('Finished ' + (new Date().toLocaleString())); diff --git a/temp/legacy.importFromCSV.ts b/temp/legacy.importFromCSV.ts index 235bc99a..71d2e570 100644 --- a/temp/legacy.importFromCSV.ts +++ b/temp/legacy.importFromCSV.ts @@ -1639,6 +1639,7 @@ function importFromWorkOrderCSV(): void { console.timeEnd('importFromWorkOrderCSV') } +console.log('Started ' + (new Date().toLocaleString())) console.time('importFromCsv') purgeTables() @@ -1648,3 +1649,4 @@ importFromPrepaidCSV() importFromWorkOrderCSV() console.timeEnd('importFromCsv') +console.log('Finished ' + (new Date().toLocaleString()))