reduce unnecessary database connections
parent
1d434264f6
commit
42dba58325
|
|
@ -22,9 +22,9 @@ export function moveLotStatusUp(lotStatusId) {
|
||||||
return result.changes > 0;
|
return result.changes > 0;
|
||||||
}
|
}
|
||||||
export function moveLotStatusUpToTop(lotStatusId) {
|
export function moveLotStatusUpToTop(lotStatusId) {
|
||||||
const database = sqlite(databasePath);
|
|
||||||
const currentOrderNumber = getLotStatusById(typeof lotStatusId === "string" ? Number.parseInt(lotStatusId) : lotStatusId).orderNumber;
|
const currentOrderNumber = getLotStatusById(typeof lotStatusId === "string" ? Number.parseInt(lotStatusId) : lotStatusId).orderNumber;
|
||||||
if (currentOrderNumber > 0) {
|
if (currentOrderNumber > 0) {
|
||||||
|
const database = sqlite(databasePath);
|
||||||
database
|
database
|
||||||
.prepare("update LotStatuses set orderNumber = -1 where lotStatusId = ?")
|
.prepare("update LotStatuses set orderNumber = -1 where lotStatusId = ?")
|
||||||
.run(lotStatusId);
|
.run(lotStatusId);
|
||||||
|
|
@ -34,9 +34,9 @@ export function moveLotStatusUpToTop(lotStatusId) {
|
||||||
where recordDelete_timeMillis is null
|
where recordDelete_timeMillis is null
|
||||||
and orderNumber < ?`)
|
and orderNumber < ?`)
|
||||||
.run(currentOrderNumber);
|
.run(currentOrderNumber);
|
||||||
|
database.close();
|
||||||
|
clearLotStatusesCache();
|
||||||
}
|
}
|
||||||
database.close();
|
|
||||||
clearLotStatusesCache();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
export default moveLotStatusUp;
|
export default moveLotStatusUp;
|
||||||
|
|
|
||||||
|
|
@ -37,13 +37,13 @@ export function moveLotStatusUp(lotStatusId: number | string): boolean {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function moveLotStatusUpToTop(lotStatusId: number | string): boolean {
|
export function moveLotStatusUpToTop(lotStatusId: number | string): boolean {
|
||||||
const database = sqlite(databasePath);
|
|
||||||
|
|
||||||
const currentOrderNumber: number = getLotStatusById(
|
const currentOrderNumber: number = getLotStatusById(
|
||||||
typeof lotStatusId === "string" ? Number.parseInt(lotStatusId) : lotStatusId
|
typeof lotStatusId === "string" ? Number.parseInt(lotStatusId) : lotStatusId
|
||||||
).orderNumber;
|
).orderNumber;
|
||||||
|
|
||||||
if (currentOrderNumber > 0) {
|
if (currentOrderNumber > 0) {
|
||||||
|
const database = sqlite(databasePath);
|
||||||
|
|
||||||
database
|
database
|
||||||
.prepare("update LotStatuses set orderNumber = -1 where lotStatusId = ?")
|
.prepare("update LotStatuses set orderNumber = -1 where lotStatusId = ?")
|
||||||
.run(lotStatusId);
|
.run(lotStatusId);
|
||||||
|
|
@ -56,12 +56,12 @@ export function moveLotStatusUpToTop(lotStatusId: number | string): boolean {
|
||||||
and orderNumber < ?`
|
and orderNumber < ?`
|
||||||
)
|
)
|
||||||
.run(currentOrderNumber);
|
.run(currentOrderNumber);
|
||||||
|
|
||||||
|
database.close();
|
||||||
|
|
||||||
|
clearLotStatusesCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
database.close();
|
|
||||||
|
|
||||||
clearLotStatusesCache();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,8 @@ export function moveLotTypeUp(lotTypeId) {
|
||||||
}
|
}
|
||||||
export function moveLotTypeUpToTop(lotTypeId) {
|
export function moveLotTypeUpToTop(lotTypeId) {
|
||||||
const currentOrderNumber = getLotTypeById(typeof lotTypeId === "string" ? Number.parseInt(lotTypeId) : lotTypeId).orderNumber;
|
const currentOrderNumber = getLotTypeById(typeof lotTypeId === "string" ? Number.parseInt(lotTypeId) : lotTypeId).orderNumber;
|
||||||
const database = sqlite(databasePath);
|
|
||||||
if (currentOrderNumber > 0) {
|
if (currentOrderNumber > 0) {
|
||||||
|
const database = sqlite(databasePath);
|
||||||
database.prepare("update LotTypes set orderNumber = -1 where lotTypeId = ?").run(lotTypeId);
|
database.prepare("update LotTypes set orderNumber = -1 where lotTypeId = ?").run(lotTypeId);
|
||||||
database
|
database
|
||||||
.prepare(`update LotTypes
|
.prepare(`update LotTypes
|
||||||
|
|
@ -31,9 +31,9 @@ export function moveLotTypeUpToTop(lotTypeId) {
|
||||||
where recordDelete_timeMillis is null
|
where recordDelete_timeMillis is null
|
||||||
and orderNumber < ?`)
|
and orderNumber < ?`)
|
||||||
.run(currentOrderNumber);
|
.run(currentOrderNumber);
|
||||||
|
database.close();
|
||||||
|
clearLotTypesCache();
|
||||||
}
|
}
|
||||||
database.close();
|
|
||||||
clearLotTypesCache();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
export default moveLotTypeUp;
|
export default moveLotTypeUp;
|
||||||
|
|
|
||||||
|
|
@ -40,9 +40,8 @@ export function moveLotTypeUpToTop(lotTypeId: number | string): boolean {
|
||||||
typeof lotTypeId === "string" ? Number.parseInt(lotTypeId) : lotTypeId
|
typeof lotTypeId === "string" ? Number.parseInt(lotTypeId) : lotTypeId
|
||||||
).orderNumber;
|
).orderNumber;
|
||||||
|
|
||||||
const database = sqlite(databasePath);
|
|
||||||
|
|
||||||
if (currentOrderNumber > 0) {
|
if (currentOrderNumber > 0) {
|
||||||
|
const database = sqlite(databasePath);
|
||||||
database.prepare("update LotTypes set orderNumber = -1 where lotTypeId = ?").run(lotTypeId);
|
database.prepare("update LotTypes set orderNumber = -1 where lotTypeId = ?").run(lotTypeId);
|
||||||
|
|
||||||
database
|
database
|
||||||
|
|
@ -53,12 +52,12 @@ export function moveLotTypeUpToTop(lotTypeId: number | string): boolean {
|
||||||
and orderNumber < ?`
|
and orderNumber < ?`
|
||||||
)
|
)
|
||||||
.run(currentOrderNumber);
|
.run(currentOrderNumber);
|
||||||
|
|
||||||
|
database.close();
|
||||||
|
|
||||||
|
clearLotTypesCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
database.close();
|
|
||||||
|
|
||||||
clearLotTypesCache();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,8 @@ export function moveOccupancyTypeUp(occupancyTypeId) {
|
||||||
}
|
}
|
||||||
export function moveOccupancyTypeUpToTop(occupancyTypeId) {
|
export function moveOccupancyTypeUpToTop(occupancyTypeId) {
|
||||||
const currentOrderNumber = getOccupancyTypeById(typeof occupancyTypeId === "string" ? Number.parseInt(occupancyTypeId) : occupancyTypeId).orderNumber;
|
const currentOrderNumber = getOccupancyTypeById(typeof occupancyTypeId === "string" ? Number.parseInt(occupancyTypeId) : occupancyTypeId).orderNumber;
|
||||||
const database = sqlite(databasePath);
|
|
||||||
if (currentOrderNumber > 0) {
|
if (currentOrderNumber > 0) {
|
||||||
|
const database = sqlite(databasePath);
|
||||||
database
|
database
|
||||||
.prepare("update OccupancyTypes set orderNumber = -1 where occupancyTypeId = ?")
|
.prepare("update OccupancyTypes set orderNumber = -1 where occupancyTypeId = ?")
|
||||||
.run(occupancyTypeId);
|
.run(occupancyTypeId);
|
||||||
|
|
@ -33,9 +33,9 @@ export function moveOccupancyTypeUpToTop(occupancyTypeId) {
|
||||||
where recordDelete_timeMillis is null
|
where recordDelete_timeMillis is null
|
||||||
and orderNumber < ?`)
|
and orderNumber < ?`)
|
||||||
.run(currentOrderNumber);
|
.run(currentOrderNumber);
|
||||||
|
database.close();
|
||||||
|
clearOccupancyTypesCache();
|
||||||
}
|
}
|
||||||
database.close();
|
|
||||||
clearOccupancyTypesCache();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
export default moveOccupancyTypeUp;
|
export default moveOccupancyTypeUp;
|
||||||
|
|
|
||||||
|
|
@ -40,9 +40,9 @@ export function moveOccupancyTypeUpToTop(occupancyTypeId: number | string): bool
|
||||||
typeof occupancyTypeId === "string" ? Number.parseInt(occupancyTypeId) : occupancyTypeId
|
typeof occupancyTypeId === "string" ? Number.parseInt(occupancyTypeId) : occupancyTypeId
|
||||||
).orderNumber;
|
).orderNumber;
|
||||||
|
|
||||||
const database = sqlite(databasePath);
|
|
||||||
|
|
||||||
if (currentOrderNumber > 0) {
|
if (currentOrderNumber > 0) {
|
||||||
|
const database = sqlite(databasePath);
|
||||||
|
|
||||||
database
|
database
|
||||||
.prepare("update OccupancyTypes set orderNumber = -1 where occupancyTypeId = ?")
|
.prepare("update OccupancyTypes set orderNumber = -1 where occupancyTypeId = ?")
|
||||||
.run(occupancyTypeId);
|
.run(occupancyTypeId);
|
||||||
|
|
@ -55,12 +55,12 @@ export function moveOccupancyTypeUpToTop(occupancyTypeId: number | string): bool
|
||||||
and orderNumber < ?`
|
and orderNumber < ?`
|
||||||
)
|
)
|
||||||
.run(currentOrderNumber);
|
.run(currentOrderNumber);
|
||||||
|
|
||||||
|
database.close();
|
||||||
|
|
||||||
|
clearOccupancyTypesCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
database.close();
|
|
||||||
|
|
||||||
clearOccupancyTypesCache();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,8 @@ export function moveWorkOrderTypeUp(workOrderTypeId) {
|
||||||
}
|
}
|
||||||
export function moveWorkOrderTypeUpToTop(workOrderTypeId) {
|
export function moveWorkOrderTypeUpToTop(workOrderTypeId) {
|
||||||
const currentOrderNumber = getWorkOrderTypeById(typeof workOrderTypeId === "string" ? Number.parseInt(workOrderTypeId) : workOrderTypeId).orderNumber;
|
const currentOrderNumber = getWorkOrderTypeById(typeof workOrderTypeId === "string" ? Number.parseInt(workOrderTypeId) : workOrderTypeId).orderNumber;
|
||||||
const database = sqlite(databasePath);
|
|
||||||
if (currentOrderNumber > 0) {
|
if (currentOrderNumber > 0) {
|
||||||
|
const database = sqlite(databasePath);
|
||||||
database
|
database
|
||||||
.prepare("update WorkOrderTypes set orderNumber = -1 where workOrderTypeId = ?")
|
.prepare("update WorkOrderTypes set orderNumber = -1 where workOrderTypeId = ?")
|
||||||
.run(workOrderTypeId);
|
.run(workOrderTypeId);
|
||||||
|
|
@ -33,9 +33,9 @@ export function moveWorkOrderTypeUpToTop(workOrderTypeId) {
|
||||||
where recordDelete_timeMillis is null
|
where recordDelete_timeMillis is null
|
||||||
and orderNumber < ?`)
|
and orderNumber < ?`)
|
||||||
.run(currentOrderNumber);
|
.run(currentOrderNumber);
|
||||||
|
database.close();
|
||||||
|
clearWorkOrderTypesCache();
|
||||||
}
|
}
|
||||||
database.close();
|
|
||||||
clearWorkOrderTypesCache();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
export default moveWorkOrderTypeUp;
|
export default moveWorkOrderTypeUp;
|
||||||
|
|
|
||||||
|
|
@ -40,9 +40,9 @@ export function moveWorkOrderTypeUpToTop(workOrderTypeId: number | string): bool
|
||||||
typeof workOrderTypeId === "string" ? Number.parseInt(workOrderTypeId) : workOrderTypeId
|
typeof workOrderTypeId === "string" ? Number.parseInt(workOrderTypeId) : workOrderTypeId
|
||||||
).orderNumber;
|
).orderNumber;
|
||||||
|
|
||||||
const database = sqlite(databasePath);
|
|
||||||
|
|
||||||
if (currentOrderNumber > 0) {
|
if (currentOrderNumber > 0) {
|
||||||
|
const database = sqlite(databasePath);
|
||||||
|
|
||||||
database
|
database
|
||||||
.prepare("update WorkOrderTypes set orderNumber = -1 where workOrderTypeId = ?")
|
.prepare("update WorkOrderTypes set orderNumber = -1 where workOrderTypeId = ?")
|
||||||
.run(workOrderTypeId);
|
.run(workOrderTypeId);
|
||||||
|
|
@ -55,12 +55,12 @@ export function moveWorkOrderTypeUpToTop(workOrderTypeId: number | string): bool
|
||||||
and orderNumber < ?`
|
and orderNumber < ?`
|
||||||
)
|
)
|
||||||
.run(currentOrderNumber);
|
.run(currentOrderNumber);
|
||||||
|
|
||||||
|
database.close();
|
||||||
|
|
||||||
|
clearWorkOrderTypesCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
database.close();
|
|
||||||
|
|
||||||
clearWorkOrderTypesCache();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue