linting
parent
1710f5ca1e
commit
b86bc6cd6a
|
|
@ -3,10 +3,8 @@ import Debug from "debug";
|
|||
const debug = Debug("lot-occupancy-system:databasePaths");
|
||||
export const useTestDatabases = configFunctions.getProperty("application.useTestDatabases") || process.env.TEST_DATABASES === "true";
|
||||
if (useTestDatabases) {
|
||||
debug("Using \"-testing\" databases.");
|
||||
debug('Using "-testing" databases.');
|
||||
}
|
||||
export const lotOccupancyDB_live = "data/lotOccupancy.db";
|
||||
export const lotOccupancyDB_testing = "data/lotOccupancy-testing.db";
|
||||
export const lotOccupancyDB = useTestDatabases
|
||||
? lotOccupancyDB_testing
|
||||
: lotOccupancyDB_live;
|
||||
export const lotOccupancyDB = useTestDatabases ? lotOccupancyDB_testing : lotOccupancyDB_live;
|
||||
|
|
|
|||
|
|
@ -9,12 +9,10 @@ export const useTestDatabases =
|
|||
configFunctions.getProperty("application.useTestDatabases") || process.env.TEST_DATABASES === "true";
|
||||
|
||||
if (useTestDatabases) {
|
||||
debug("Using \"-testing\" databases.");
|
||||
debug('Using "-testing" databases.');
|
||||
}
|
||||
|
||||
export const lotOccupancyDB_live = "data/lotOccupancy.db";
|
||||
export const lotOccupancyDB_testing = "data/lotOccupancy-testing.db";
|
||||
|
||||
export const lotOccupancyDB = useTestDatabases
|
||||
? lotOccupancyDB_testing
|
||||
: lotOccupancyDB_live;
|
||||
export const lotOccupancyDB = useTestDatabases ? lotOccupancyDB_testing : lotOccupancyDB_live;
|
||||
|
|
|
|||
|
|
@ -3,17 +3,14 @@ import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
|||
import { getLotFields } from "./getLotFields.js";
|
||||
import { getLotComments } from "./getLotComments.js";
|
||||
import { getLotOccupancies } from "./getLotOccupancies.js";
|
||||
const baseSQL = "select l.lotId," +
|
||||
" l.lotTypeId, t.lotType," +
|
||||
" l.lotName," +
|
||||
" l.lotStatusId, s.lotStatus," +
|
||||
" l.mapId, m.mapName, m.mapSVG, l.mapKey," +
|
||||
" l.lotLatitude, l.lotLongitude" +
|
||||
" from Lots l" +
|
||||
" left join LotTypes t on l.lotTypeId = t.lotTypeId" +
|
||||
" left join LotStatuses s on l.lotStatusId = s.lotStatusId" +
|
||||
" left join Maps m on l.mapId = m.mapId" +
|
||||
" where l.recordDelete_timeMillis is null";
|
||||
const baseSQL = `select l.lotId, l.lotTypeId, t.lotType, l.lotName, l.lotStatusId, s.lotStatus,
|
||||
l.mapId, m.mapName, m.mapSVG, l.mapKey,
|
||||
l.lotLatitude, l.lotLongitude
|
||||
from Lots l
|
||||
left join LotTypes t on l.lotTypeId = t.lotTypeId
|
||||
left join LotStatuses s on l.lotStatusId = s.lotStatusId
|
||||
left join Maps m on l.mapId = m.mapId
|
||||
where l.recordDelete_timeMillis is null`;
|
||||
function _getLot(sql, lotId_or_lotName) {
|
||||
const database = sqlite(databasePath, {
|
||||
readonly: true
|
||||
|
|
|
|||
|
|
@ -10,18 +10,14 @@ import { getLotOccupancies } from "./getLotOccupancies.js";
|
|||
|
||||
import type * as recordTypes from "../../types/recordTypes";
|
||||
|
||||
const baseSQL =
|
||||
"select l.lotId," +
|
||||
" l.lotTypeId, t.lotType," +
|
||||
" l.lotName," +
|
||||
" l.lotStatusId, s.lotStatus," +
|
||||
" l.mapId, m.mapName, m.mapSVG, l.mapKey," +
|
||||
" l.lotLatitude, l.lotLongitude" +
|
||||
" from Lots l" +
|
||||
" left join LotTypes t on l.lotTypeId = t.lotTypeId" +
|
||||
" left join LotStatuses s on l.lotStatusId = s.lotStatusId" +
|
||||
" left join Maps m on l.mapId = m.mapId" +
|
||||
" where l.recordDelete_timeMillis is null";
|
||||
const baseSQL = `select l.lotId, l.lotTypeId, t.lotType, l.lotName, l.lotStatusId, s.lotStatus,
|
||||
l.mapId, m.mapName, m.mapSVG, l.mapKey,
|
||||
l.lotLatitude, l.lotLongitude
|
||||
from Lots l
|
||||
left join LotTypes t on l.lotTypeId = t.lotTypeId
|
||||
left join LotStatuses s on l.lotStatusId = s.lotStatusId
|
||||
left join Maps m on l.mapId = m.mapId
|
||||
where l.recordDelete_timeMillis is null`;
|
||||
|
||||
function _getLot(sql: string, lotId_or_lotName: number | string): recordTypes.Lot | undefined {
|
||||
const database = sqlite(databasePath, {
|
||||
|
|
|
|||
|
|
@ -29,8 +29,7 @@ function buildWhereClause(filters) {
|
|||
break;
|
||||
}
|
||||
case "recent": {
|
||||
sqlWhereClause +=
|
||||
" and m.workOrderMilestoneDate >= ? and m.workOrderMilestoneDate <= ?";
|
||||
sqlWhereClause += " and m.workOrderMilestoneDate >= ? and m.workOrderMilestoneDate <= ?";
|
||||
sqlParameters.push(recentBeforeDateNumber, recentAfterDateNumber);
|
||||
break;
|
||||
}
|
||||
|
|
@ -44,8 +43,7 @@ function buildWhereClause(filters) {
|
|||
}
|
||||
if (filters.workOrderMilestoneTypeIds &&
|
||||
commaSeparatedNumbersRegex.test(filters.workOrderMilestoneTypeIds)) {
|
||||
sqlWhereClause +=
|
||||
" and m.workOrderMilestoneTypeId in (" + filters.workOrderMilestoneTypeIds + ")";
|
||||
sqlWhereClause += " and m.workOrderMilestoneTypeId in (" + filters.workOrderMilestoneTypeIds + ")";
|
||||
}
|
||||
return {
|
||||
sqlWhereClause,
|
||||
|
|
@ -98,9 +96,7 @@ export function getWorkOrderMilestones(filters, options, connectedDatabase) {
|
|||
" left join WorkOrderTypes wt on w.workOrderTypeId = wt.workOrderTypeId" +
|
||||
sqlWhereClause +
|
||||
orderByClause;
|
||||
const workOrderMilestones = database
|
||||
.prepare(sql)
|
||||
.all(sqlParameters);
|
||||
const workOrderMilestones = database.prepare(sql).all(sqlParameters);
|
||||
if (options.includeWorkOrders) {
|
||||
for (const workOrderMilestone of workOrderMilestones) {
|
||||
workOrderMilestone.workOrderLots = getLots({
|
||||
|
|
|
|||
|
|
@ -35,8 +35,7 @@ function buildWhereClause(filters: WorkOrderMilestoneFilters): {
|
|||
sqlWhereClause: string;
|
||||
sqlParameters: unknown[];
|
||||
} {
|
||||
let sqlWhereClause =
|
||||
" where m.recordDelete_timeMillis is null and w.recordDelete_timeMillis is null";
|
||||
let sqlWhereClause = " where m.recordDelete_timeMillis is null and w.recordDelete_timeMillis is null";
|
||||
const sqlParameters: unknown[] = [];
|
||||
|
||||
if (filters.workOrderId) {
|
||||
|
|
@ -49,18 +48,14 @@ function buildWhereClause(filters: WorkOrderMilestoneFilters): {
|
|||
|
||||
date.setDate(
|
||||
date.getDate() -
|
||||
configFunctions.getProperty(
|
||||
"settings.workOrders.workOrderMilestoneDateRecentBeforeDays"
|
||||
)
|
||||
configFunctions.getProperty("settings.workOrders.workOrderMilestoneDateRecentBeforeDays")
|
||||
);
|
||||
|
||||
const recentBeforeDateNumber = dateToInteger(date);
|
||||
|
||||
date.setDate(
|
||||
date.getDate() +
|
||||
configFunctions.getProperty(
|
||||
"settings.workOrders.workOrderMilestoneDateRecentBeforeDays"
|
||||
) +
|
||||
configFunctions.getProperty("settings.workOrders.workOrderMilestoneDateRecentBeforeDays") +
|
||||
configFunctions.getProperty("settings.workOrders.workOrderMilestoneDateRecentAfterDays")
|
||||
);
|
||||
|
||||
|
|
@ -75,8 +70,7 @@ function buildWhereClause(filters: WorkOrderMilestoneFilters): {
|
|||
}
|
||||
|
||||
case "recent": {
|
||||
sqlWhereClause +=
|
||||
" and m.workOrderMilestoneDate >= ? and m.workOrderMilestoneDate <= ?";
|
||||
sqlWhereClause += " and m.workOrderMilestoneDate >= ? and m.workOrderMilestoneDate <= ?";
|
||||
sqlParameters.push(recentBeforeDateNumber, recentAfterDateNumber);
|
||||
break;
|
||||
}
|
||||
|
|
@ -95,8 +89,7 @@ function buildWhereClause(filters: WorkOrderMilestoneFilters): {
|
|||
filters.workOrderMilestoneTypeIds &&
|
||||
commaSeparatedNumbersRegex.test(filters.workOrderMilestoneTypeIds)
|
||||
) {
|
||||
sqlWhereClause +=
|
||||
" and m.workOrderMilestoneTypeId in (" + filters.workOrderMilestoneTypeIds + ")";
|
||||
sqlWhereClause += " and m.workOrderMilestoneTypeId in (" + filters.workOrderMilestoneTypeIds + ")";
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
@ -167,9 +160,7 @@ export function getWorkOrderMilestones(
|
|||
sqlWhereClause +
|
||||
orderByClause;
|
||||
|
||||
const workOrderMilestones: recordTypes.WorkOrderMilestone[] = database
|
||||
.prepare(sql)
|
||||
.all(sqlParameters);
|
||||
const workOrderMilestones: recordTypes.WorkOrderMilestone[] = database.prepare(sql).all(sqlParameters);
|
||||
|
||||
if (options.includeWorkOrders) {
|
||||
for (const workOrderMilestone of workOrderMilestones) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue