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