linting
parent
71e2d0d9e8
commit
f98179b433
|
|
@ -19,9 +19,10 @@ function buildWhereClause(filters) {
|
||||||
const occupantNameFilters = getOccupantNameWhereClause(filters.occupantName, 'o');
|
const occupantNameFilters = getOccupantNameWhereClause(filters.occupantName, 'o');
|
||||||
if (occupantNameFilters.sqlParameters.length > 0) {
|
if (occupantNameFilters.sqlParameters.length > 0) {
|
||||||
sqlWhereClause +=
|
sqlWhereClause +=
|
||||||
' and o.lotOccupancyId in (select lotOccupancyId from LotOccupancyOccupants o where recordDelete_timeMillis is null' +
|
` and o.lotOccupancyId in (
|
||||||
occupantNameFilters.sqlWhereClause +
|
select lotOccupancyId from LotOccupancyOccupants o
|
||||||
')';
|
where recordDelete_timeMillis is null
|
||||||
|
${occupantNameFilters.sqlWhereClause})`;
|
||||||
sqlParameters.push(...occupantNameFilters.sqlParameters);
|
sqlParameters.push(...occupantNameFilters.sqlParameters);
|
||||||
}
|
}
|
||||||
if ((filters.occupancyTypeId ?? '') !== '') {
|
if ((filters.occupancyTypeId ?? '') !== '') {
|
||||||
|
|
@ -106,8 +107,8 @@ export default async function getLotOccupancies(filters, options, connectedDatab
|
||||||
left join LotTypes lt on l.lotTypeId = lt.lotTypeId
|
left join LotTypes lt on l.lotTypeId = lt.lotTypeId
|
||||||
left join Maps m on l.mapId = m.mapId
|
left join Maps m on l.mapId = m.mapId
|
||||||
${sqlWhereClause}
|
${sqlWhereClause}
|
||||||
order by o.occupancyStartDate desc, ifnull(o.occupancyEndDate, 99999999) desc, l.lotName, o.lotId, o.lotOccupancyId desc` +
|
order by o.occupancyStartDate desc, ifnull(o.occupancyEndDate, 99999999) desc, l.lotName, o.lotId, o.lotOccupancyId desc
|
||||||
(isLimited ? ` limit ${options.limit} offset ${options.offset}` : ''))
|
${isLimited ? ` limit ${options.limit} offset ${options.offset}` : ''}`)
|
||||||
.all(sqlParameters);
|
.all(sqlParameters);
|
||||||
if (!isLimited) {
|
if (!isLimited) {
|
||||||
count = lotOccupancies.length;
|
count = lotOccupancies.length;
|
||||||
|
|
|
||||||
|
|
@ -68,9 +68,10 @@ function buildWhereClause(filters: GetLotOccupanciesFilters): {
|
||||||
)
|
)
|
||||||
if (occupantNameFilters.sqlParameters.length > 0) {
|
if (occupantNameFilters.sqlParameters.length > 0) {
|
||||||
sqlWhereClause +=
|
sqlWhereClause +=
|
||||||
' and o.lotOccupancyId in (select lotOccupancyId from LotOccupancyOccupants o where recordDelete_timeMillis is null' +
|
` and o.lotOccupancyId in (
|
||||||
occupantNameFilters.sqlWhereClause +
|
select lotOccupancyId from LotOccupancyOccupants o
|
||||||
')'
|
where recordDelete_timeMillis is null
|
||||||
|
${occupantNameFilters.sqlWhereClause})`
|
||||||
sqlParameters.push(...occupantNameFilters.sqlParameters)
|
sqlParameters.push(...occupantNameFilters.sqlParameters)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -207,8 +208,10 @@ export default async function getLotOccupancies(
|
||||||
left join LotTypes lt on l.lotTypeId = lt.lotTypeId
|
left join LotTypes lt on l.lotTypeId = lt.lotTypeId
|
||||||
left join Maps m on l.mapId = m.mapId
|
left join Maps m on l.mapId = m.mapId
|
||||||
${sqlWhereClause}
|
${sqlWhereClause}
|
||||||
order by o.occupancyStartDate desc, ifnull(o.occupancyEndDate, 99999999) desc, l.lotName, o.lotId, o.lotOccupancyId desc` +
|
order by o.occupancyStartDate desc, ifnull(o.occupancyEndDate, 99999999) desc, l.lotName, o.lotId, o.lotOccupancyId desc
|
||||||
(isLimited ? ` limit ${options.limit} offset ${options.offset}` : '')
|
${
|
||||||
|
isLimited ? ` limit ${options.limit} offset ${options.offset}` : ''
|
||||||
|
}`
|
||||||
)
|
)
|
||||||
.all(sqlParameters) as LotOccupancy[]
|
.all(sqlParameters) as LotOccupancy[]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,12 +57,12 @@ async function _getWorkOrder(sql, workOrderIdOrWorkOrderNumber, options, connect
|
||||||
return workOrder;
|
return workOrder;
|
||||||
}
|
}
|
||||||
export async function getWorkOrderByWorkOrderNumber(workOrderNumber) {
|
export async function getWorkOrderByWorkOrderNumber(workOrderNumber) {
|
||||||
return await _getWorkOrder(baseSQL + ' and w.workOrderNumber = ?', workOrderNumber, {
|
return await _getWorkOrder(`${baseSQL} and w.workOrderNumber = ?`, workOrderNumber, {
|
||||||
includeLotsAndLotOccupancies: true,
|
includeLotsAndLotOccupancies: true,
|
||||||
includeComments: true,
|
includeComments: true,
|
||||||
includeMilestones: true
|
includeMilestones: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
export default async function getWorkOrder(workOrderId, options, connectedDatabase) {
|
export default async function getWorkOrder(workOrderId, options, connectedDatabase) {
|
||||||
return await _getWorkOrder(baseSQL + ' and w.workOrderId = ?', workOrderId, options, connectedDatabase);
|
return await _getWorkOrder(`${baseSQL} and w.workOrderId = ?`, workOrderId, options, connectedDatabase);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,7 @@ export async function getWorkOrderByWorkOrderNumber(
|
||||||
workOrderNumber: string
|
workOrderNumber: string
|
||||||
): Promise<WorkOrder | undefined> {
|
): Promise<WorkOrder | undefined> {
|
||||||
return await _getWorkOrder(
|
return await _getWorkOrder(
|
||||||
baseSQL + ' and w.workOrderNumber = ?',
|
`${baseSQL} and w.workOrderNumber = ?`,
|
||||||
workOrderNumber,
|
workOrderNumber,
|
||||||
{
|
{
|
||||||
includeLotsAndLotOccupancies: true,
|
includeLotsAndLotOccupancies: true,
|
||||||
|
|
@ -121,7 +121,7 @@ export default async function getWorkOrder(
|
||||||
connectedDatabase?: PoolConnection
|
connectedDatabase?: PoolConnection
|
||||||
): Promise<WorkOrder | undefined> {
|
): Promise<WorkOrder | undefined> {
|
||||||
return await _getWorkOrder(
|
return await _getWorkOrder(
|
||||||
baseSQL + ' and w.workOrderId = ?',
|
`${baseSQL} and w.workOrderId = ?`,
|
||||||
workOrderId,
|
workOrderId,
|
||||||
options,
|
options,
|
||||||
connectedDatabase
|
connectedDatabase
|
||||||
|
|
|
||||||
|
|
@ -27,22 +27,26 @@ function buildWhereClause(filters) {
|
||||||
const occupantNameFilters = getOccupantNameWhereClause(filters.occupantName, 'o');
|
const occupantNameFilters = getOccupantNameWhereClause(filters.occupantName, 'o');
|
||||||
if (occupantNameFilters.sqlParameters.length > 0) {
|
if (occupantNameFilters.sqlParameters.length > 0) {
|
||||||
sqlWhereClause +=
|
sqlWhereClause +=
|
||||||
' and w.workOrderId in (' +
|
` and w.workOrderId in (
|
||||||
'select workOrderId from WorkOrderLotOccupancies o' +
|
select workOrderId from WorkOrderLotOccupancies o
|
||||||
' where recordDelete_timeMillis is null' +
|
where recordDelete_timeMillis is null
|
||||||
' and o.lotOccupancyId in (select lotOccupancyId from LotOccupancyOccupants o where recordDelete_timeMillis is null' +
|
and o.lotOccupancyId in (
|
||||||
occupantNameFilters.sqlWhereClause +
|
select lotOccupancyId from LotOccupancyOccupants o where recordDelete_timeMillis is null
|
||||||
')' +
|
${occupantNameFilters.sqlWhereClause}
|
||||||
')';
|
))`;
|
||||||
sqlParameters.push(...occupantNameFilters.sqlParameters);
|
sqlParameters.push(...occupantNameFilters.sqlParameters);
|
||||||
}
|
}
|
||||||
const lotNameFilters = getLotNameWhereClause(filters.lotName, '', 'l');
|
const lotNameFilters = getLotNameWhereClause(filters.lotName, '', 'l');
|
||||||
if (lotNameFilters.sqlParameters.length > 0) {
|
if (lotNameFilters.sqlParameters.length > 0) {
|
||||||
sqlWhereClause +=
|
sqlWhereClause +=
|
||||||
' and w.workOrderId in (' +
|
` and w.workOrderId in (
|
||||||
'select workOrderId from WorkOrderLots where recordDelete_timeMillis is null and lotId in (select lotId from Lots l where recordDelete_timeMillis is null' +
|
select workOrderId from WorkOrderLots
|
||||||
lotNameFilters.sqlWhereClause +
|
where recordDelete_timeMillis is null
|
||||||
'))';
|
and lotId in (
|
||||||
|
select lotId from Lots l
|
||||||
|
where recordDelete_timeMillis is null
|
||||||
|
${lotNameFilters.sqlWhereClause}
|
||||||
|
))`;
|
||||||
sqlParameters.push(...lotNameFilters.sqlParameters);
|
sqlParameters.push(...lotNameFilters.sqlParameters);
|
||||||
}
|
}
|
||||||
if ((filters.lotOccupancyId ?? '') !== '') {
|
if ((filters.lotOccupancyId ?? '') !== '') {
|
||||||
|
|
|
||||||
|
|
@ -67,23 +67,27 @@ function buildWhereClause(filters: GetWorkOrdersFilters): {
|
||||||
)
|
)
|
||||||
if (occupantNameFilters.sqlParameters.length > 0) {
|
if (occupantNameFilters.sqlParameters.length > 0) {
|
||||||
sqlWhereClause +=
|
sqlWhereClause +=
|
||||||
' and w.workOrderId in (' +
|
` and w.workOrderId in (
|
||||||
'select workOrderId from WorkOrderLotOccupancies o' +
|
select workOrderId from WorkOrderLotOccupancies o
|
||||||
' where recordDelete_timeMillis is null' +
|
where recordDelete_timeMillis is null
|
||||||
' and o.lotOccupancyId in (select lotOccupancyId from LotOccupancyOccupants o where recordDelete_timeMillis is null' +
|
and o.lotOccupancyId in (
|
||||||
occupantNameFilters.sqlWhereClause +
|
select lotOccupancyId from LotOccupancyOccupants o where recordDelete_timeMillis is null
|
||||||
')' +
|
${occupantNameFilters.sqlWhereClause}
|
||||||
')'
|
))`
|
||||||
sqlParameters.push(...occupantNameFilters.sqlParameters)
|
sqlParameters.push(...occupantNameFilters.sqlParameters)
|
||||||
}
|
}
|
||||||
|
|
||||||
const lotNameFilters = getLotNameWhereClause(filters.lotName, '', 'l')
|
const lotNameFilters = getLotNameWhereClause(filters.lotName, '', 'l')
|
||||||
if (lotNameFilters.sqlParameters.length > 0) {
|
if (lotNameFilters.sqlParameters.length > 0) {
|
||||||
sqlWhereClause +=
|
sqlWhereClause +=
|
||||||
' and w.workOrderId in (' +
|
` and w.workOrderId in (
|
||||||
'select workOrderId from WorkOrderLots where recordDelete_timeMillis is null and lotId in (select lotId from Lots l where recordDelete_timeMillis is null' +
|
select workOrderId from WorkOrderLots
|
||||||
lotNameFilters.sqlWhereClause +
|
where recordDelete_timeMillis is null
|
||||||
'))'
|
and lotId in (
|
||||||
|
select lotId from Lots l
|
||||||
|
where recordDelete_timeMillis is null
|
||||||
|
${lotNameFilters.sqlWhereClause}
|
||||||
|
))`
|
||||||
sqlParameters.push(...lotNameFilters.sqlParameters)
|
sqlParameters.push(...lotNameFilters.sqlParameters)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,12 +9,9 @@ function escapeHTML(stringToEscape) {
|
||||||
return stringToEscape.replaceAll(/[^\d a-z]/gi, (c) => `&#${c.codePointAt(0)};`);
|
return stringToEscape.replaceAll(/[^\d a-z]/gi, (c) => `&#${c.codePointAt(0)};`);
|
||||||
}
|
}
|
||||||
function getUrlRoot(request) {
|
function getUrlRoot(request) {
|
||||||
return ('http://' +
|
return `http://${request.hostname}${getConfigProperty('application.httpPort') === 80
|
||||||
request.hostname +
|
? ''
|
||||||
(getConfigProperty('application.httpPort') === 80
|
: `:${getConfigProperty('application.httpPort')}`}${getConfigProperty('reverseProxy.urlPrefix')}`;
|
||||||
? ''
|
|
||||||
: `:${getConfigProperty('application.httpPort')}`) +
|
|
||||||
getConfigProperty('reverseProxy.urlPrefix'));
|
|
||||||
}
|
}
|
||||||
function getWorkOrderUrl(request, milestone) {
|
function getWorkOrderUrl(request, milestone) {
|
||||||
return `${getUrlRoot(request)}/workOrders/${milestone.workOrderId}`;
|
return `${getUrlRoot(request)}/workOrders/${milestone.workOrderId}`;
|
||||||
|
|
@ -32,10 +29,7 @@ function buildEventSummary(milestone) {
|
||||||
if (summary !== '') {
|
if (summary !== '') {
|
||||||
summary += ': ';
|
summary += ': ';
|
||||||
}
|
}
|
||||||
summary +=
|
summary += `${occupant.occupantName ?? ''} ${occupant.occupantFamilyName ?? ''}`;
|
||||||
(occupant.occupantName ?? '') +
|
|
||||||
' ' +
|
|
||||||
(occupant.occupantFamilyName ?? '');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,14 +23,11 @@ function escapeHTML(stringToEscape: string): string {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUrlRoot(request: Request): string {
|
function getUrlRoot(request: Request): string {
|
||||||
return (
|
return `http://${request.hostname}${
|
||||||
'http://' +
|
getConfigProperty('application.httpPort') === 80
|
||||||
request.hostname +
|
|
||||||
(getConfigProperty('application.httpPort') === 80
|
|
||||||
? ''
|
? ''
|
||||||
: `:${getConfigProperty('application.httpPort')}`) +
|
: `:${getConfigProperty('application.httpPort')}`
|
||||||
getConfigProperty('reverseProxy.urlPrefix')
|
}${getConfigProperty('reverseProxy.urlPrefix')}`
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getWorkOrderUrl(
|
function getWorkOrderUrl(
|
||||||
|
|
@ -59,10 +56,7 @@ function buildEventSummary(milestone: WorkOrderMilestone): string {
|
||||||
summary += ': '
|
summary += ': '
|
||||||
}
|
}
|
||||||
|
|
||||||
summary +=
|
summary += `${occupant.occupantName ?? ''} ${occupant.occupantFamilyName ?? ''}`
|
||||||
(occupant.occupantName ?? '') +
|
|
||||||
' ' +
|
|
||||||
(occupant.occupantFamilyName ?? '')
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import { getConfigProperty } from '../../helpers/functions.config.js';
|
||||||
export default async function handler(request, response) {
|
export default async function handler(request, response) {
|
||||||
const lot = await getLot(request.params.lotId);
|
const lot = await getLot(request.params.lotId);
|
||||||
if (lot === undefined) {
|
if (lot === undefined) {
|
||||||
response.redirect(getConfigProperty('reverseProxy.urlPrefix') + '/lots/?error=lotIdNotFound');
|
response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/lots/?error=lotIdNotFound`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const maps = await getMaps();
|
const maps = await getMaps();
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ export default async function handler(
|
||||||
|
|
||||||
if (lot === undefined) {
|
if (lot === undefined) {
|
||||||
response.redirect(
|
response.redirect(
|
||||||
getConfigProperty('reverseProxy.urlPrefix') + '/lots/?error=lotIdNotFound'
|
`${getConfigProperty('reverseProxy.urlPrefix')}/lots/?error=lotIdNotFound`
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,7 @@ export async function handler(request, response, next) {
|
||||||
}
|
}
|
||||||
const printConfig = getPdfPrintConfig(printName);
|
const printConfig = getPdfPrintConfig(printName);
|
||||||
if (printConfig === undefined) {
|
if (printConfig === undefined) {
|
||||||
response.redirect(configFunctions.getConfigProperty('reverseProxy.urlPrefix') +
|
response.redirect(`${configFunctions.getConfigProperty('reverseProxy.urlPrefix')}/dashboard/?error=printConfigNotFound`);
|
||||||
'/dashboard/?error=printConfigNotFound');
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const reportData = await getReportData(printConfig, request.query);
|
const reportData = await getReportData(printConfig, request.query);
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import path from 'node:path'
|
||||||
import { convertHTMLToPDF } from '@cityssm/pdf-puppeteer'
|
import { convertHTMLToPDF } from '@cityssm/pdf-puppeteer'
|
||||||
import * as dateTimeFunctions from '@cityssm/utils-datetime'
|
import * as dateTimeFunctions from '@cityssm/utils-datetime'
|
||||||
import camelcase from 'camelcase'
|
import camelcase from 'camelcase'
|
||||||
import {renderFile as renderEjsFile } from 'ejs'
|
import { renderFile as renderEjsFile } from 'ejs'
|
||||||
import type { NextFunction, Request, Response } from 'express'
|
import type { NextFunction, Request, Response } from 'express'
|
||||||
|
|
||||||
import * as configFunctions from '../../helpers/functions.config.js'
|
import * as configFunctions from '../../helpers/functions.config.js'
|
||||||
|
|
@ -44,8 +44,7 @@ export async function handler(
|
||||||
|
|
||||||
if (printConfig === undefined) {
|
if (printConfig === undefined) {
|
||||||
response.redirect(
|
response.redirect(
|
||||||
configFunctions.getConfigProperty('reverseProxy.urlPrefix') +
|
`${configFunctions.getConfigProperty('reverseProxy.urlPrefix')}/dashboard/?error=printConfigNotFound`
|
||||||
'/dashboard/?error=printConfigNotFound'
|
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,7 @@ export default async function handler(request, response) {
|
||||||
}
|
}
|
||||||
const printConfig = getScreenPrintConfig(printName);
|
const printConfig = getScreenPrintConfig(printName);
|
||||||
if (printConfig === undefined) {
|
if (printConfig === undefined) {
|
||||||
response.redirect(getConfigProperty('reverseProxy.urlPrefix') +
|
response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/dashboard/?error=printConfigNotFound`);
|
||||||
'/dashboard/?error=printConfigNotFound');
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const reportData = await getReportData(printConfig, request.query);
|
const reportData = await getReportData(printConfig, request.query);
|
||||||
|
|
|
||||||
|
|
@ -32,8 +32,7 @@ export default async function handler(
|
||||||
|
|
||||||
if (printConfig === undefined) {
|
if (printConfig === undefined) {
|
||||||
response.redirect(
|
response.redirect(
|
||||||
getConfigProperty('reverseProxy.urlPrefix') +
|
`${getConfigProperty('reverseProxy.urlPrefix')}/dashboard/?error=printConfigNotFound`
|
||||||
'/dashboard/?error=printConfigNotFound'
|
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ export function initializeDatabase() {
|
||||||
.prepare("select name from sqlite_master where type = 'table' and name = 'WorkOrderMilestones'")
|
.prepare("select name from sqlite_master where type = 'table' and name = 'WorkOrderMilestones'")
|
||||||
.get();
|
.get();
|
||||||
if (row === undefined) {
|
if (row === undefined) {
|
||||||
debugSQL('Creating ' + databasePath);
|
debugSQL(`Creating ${databasePath}`);
|
||||||
for (const sql of createStatements) {
|
for (const sql of createStatements) {
|
||||||
lotOccupancyDB.prepare(sql).run();
|
lotOccupancyDB.prepare(sql).run();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,7 @@ export function initializeDatabase(): boolean {
|
||||||
.get()
|
.get()
|
||||||
|
|
||||||
if (row === undefined) {
|
if (row === undefined) {
|
||||||
debugSQL('Creating ' + databasePath)
|
debugSQL(`Creating ${databasePath}`)
|
||||||
|
|
||||||
for (const sql of createStatements) {
|
for (const sql of createStatements) {
|
||||||
lotOccupancyDB.prepare(sql).run()
|
lotOccupancyDB.prepare(sql).run()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue