code cleanup

deepsource-autofix-76c6eb20
Dan Gowans 2023-12-11 15:49:31 -05:00
parent f6721dfc60
commit 535c2c50f1
12 changed files with 30 additions and 26 deletions

View File

@ -20,7 +20,7 @@ cluster.setupPrimary(clusterSettings);
const activeWorkers = new Map();
for (let index = 0; index < processCount; index += 1) {
const worker = cluster.fork();
activeWorkers.set(worker.process.pid, worker);
activeWorkers.set(worker.process.pid ?? 0, worker);
}
cluster.on('message', (worker, message) => {
for (const [pid, activeWorker] of activeWorkers.entries()) {
@ -31,9 +31,9 @@ cluster.on('message', (worker, message) => {
worker.send(message);
}
});
cluster.on('exit', (worker, code, signal) => {
debug(`Worker ${worker.process.pid.toString()} has been killed`);
activeWorkers.delete(worker.process.pid);
cluster.on('exit', (worker) => {
debug(`Worker ${(worker.process.pid ?? 0).toString()} has been killed`);
activeWorkers.delete(worker.process.pid ?? 0);
debug('Starting another worker');
cluster.fork();
});

View File

@ -37,7 +37,7 @@ const activeWorkers = new Map<number, Worker>()
for (let index = 0; index < processCount; index += 1) {
const worker = cluster.fork()
activeWorkers.set(worker.process.pid!, worker)
activeWorkers.set(worker.process.pid ?? 0, worker)
}
cluster.on('message', (worker, message: WorkerMessage) => {
@ -51,9 +51,9 @@ cluster.on('message', (worker, message: WorkerMessage) => {
}
})
cluster.on('exit', (worker, code, signal) => {
debug(`Worker ${worker.process.pid!.toString()} has been killed`)
activeWorkers.delete(worker.process.pid!)
cluster.on('exit', (worker) => {
debug(`Worker ${(worker.process.pid ?? 0).toString()} has been killed`)
activeWorkers.delete(worker.process.pid ?? 0)
debug('Starting another worker')
cluster.fork()

View File

@ -9,7 +9,7 @@ export async function addLotOccupancyFee(lotOccupancyFeeForm, user) {
let taxAmount;
if ((lotOccupancyFeeForm.feeAmount ?? '') === '') {
const lotOccupancy = (await getLotOccupancy(lotOccupancyFeeForm.lotOccupancyId));
const fee = await getFee(lotOccupancyFeeForm.feeId);
const fee = (await getFee(lotOccupancyFeeForm.feeId));
feeAmount = calculateFeeAmount(fee, lotOccupancy);
taxAmount = calculateTaxAmount(fee, feeAmount);
}

View File

@ -1,5 +1,8 @@
import type { LotOccupancy } from '../types/recordTypes.js'
import { calculateFeeAmount, calculateTaxAmount } from '../helpers/functions.fee.js'
import {
calculateFeeAmount,
calculateTaxAmount
} from '../helpers/functions.fee.js'
import type { Fee, LotOccupancy } from '../types/recordTypes.js'
import { getFee } from './getFee.js'
import { getLotOccupancy } from './getLotOccupancy.js'
@ -30,7 +33,7 @@ export async function addLotOccupancyFee(
lotOccupancyFeeForm.lotOccupancyId
)) as LotOccupancy
const fee = await getFee(lotOccupancyFeeForm.feeId)
const fee = (await getFee(lotOccupancyFeeForm.feeId)) as Fee
feeAmount = calculateFeeAmount(fee, lotOccupancy)
taxAmount = calculateTaxAmount(fee, feeAmount)

View File

@ -136,14 +136,14 @@ async function addInclusions(
): Promise<LotOccupancy> {
if (options.includeFees) {
lotOccupancy.lotOccupancyFees = await getLotOccupancyFees(
lotOccupancy.lotOccupancyId!,
lotOccupancy.lotOccupancyId,
database
)
}
if (options.includeTransactions) {
lotOccupancy.lotOccupancyTransactions = await getLotOccupancyTransactions(
lotOccupancy.lotOccupancyId!,
lotOccupancy.lotOccupancyId,
{ includeIntegrations: false },
database
)
@ -151,7 +151,7 @@ async function addInclusions(
if (options.includeOccupants) {
lotOccupancy.lotOccupancyOccupants = await getLotOccupancyOccupants(
lotOccupancy.lotOccupancyId!,
lotOccupancy.lotOccupancyId,
database
)
}

View File

@ -106,7 +106,7 @@ async function addInclusions(
): Promise<WorkOrder> {
if (options.includeComments ?? false) {
workOrder.workOrderComments = await getWorkOrderComments(
workOrder.workOrderId!,
workOrder.workOrderId,
database
)
}

View File

@ -56,7 +56,7 @@ export async function moveFeeUp(feeId) {
}
export async function moveFeeUpToTop(feeId) {
const database = await acquireConnection();
const currentFee = await getFee(feeId, database);
const currentFee = (await getFee(feeId, database));
if (currentFee.orderNumber > 0) {
updateRecordOrderNumber('Fees', feeId, -1, database);
database

View File

@ -1,3 +1,4 @@
import { Fee } from '../types/recordTypes.js'
import { getFee } from './getFee.js'
import { acquireConnection } from './pool.js'
import { updateRecordOrderNumber } from './updateRecordOrderNumber.js'
@ -100,7 +101,7 @@ export async function moveFeeUp(feeId: number): Promise<boolean> {
export async function moveFeeUpToTop(feeId: number | string): Promise<boolean> {
const database = await acquireConnection()
const currentFee = await getFee(feeId, database)
const currentFee = (await getFee(feeId, database)) as Fee
if (currentFee.orderNumber! > 0) {
updateRecordOrderNumber('Fees', feeId, -1, database)

View File

@ -21,7 +21,7 @@ export async function handler(
): Promise<void> {
const startDate = new Date()
const lotOccupancy: LotOccupancy = {
const lotOccupancy: Partial<LotOccupancy> = {
occupancyStartDate: dateToInteger(startDate),
occupancyStartDateString: dateToString(startDate)
}

View File

@ -10,7 +10,7 @@ export async function handler(
): Promise<void> {
const currentDate = new Date()
const workOrder: WorkOrder = {
const workOrder: Partial<WorkOrder> = {
workOrderOpenDate: dateToInteger(currentDate),
workOrderOpenDateString: dateToString(currentDate)
}

View File

@ -187,12 +187,12 @@ export interface LotOccupancyComment extends Record {
lotOccupancyComment?: string;
}
export interface LotOccupancyField extends OccupancyTypeField, Record {
lotOccupancyId?: number;
occupancyTypeFieldId?: number;
lotOccupancyId: number;
occupancyTypeFieldId: number;
lotOccupancyFieldValue?: string;
}
export interface LotOccupancy extends Record {
lotOccupancyId?: number;
lotOccupancyId: number;
occupancyTypeId?: number;
occupancyType?: string;
printEJS?: string;

View File

@ -245,13 +245,13 @@ export interface LotOccupancyComment extends Record {
}
export interface LotOccupancyField extends OccupancyTypeField, Record {
lotOccupancyId?: number
occupancyTypeFieldId?: number
lotOccupancyId: number
occupancyTypeFieldId: number
lotOccupancyFieldValue?: string
}
export interface LotOccupancy extends Record {
lotOccupancyId?: number
lotOccupancyId: number
occupancyTypeId?: number
occupancyType?: string