refs #2687 perf: remove comments

This commit is contained in:
Javier Segarra 2023-12-15 07:34:37 +01:00
parent d9ffdaf855
commit b5b58faee4
3 changed files with 8 additions and 26 deletions

View File

@ -10,8 +10,7 @@ CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`travel_cloneWithEntries`(
IN vWarehouseInFk INT,
IN vRef VARCHAR(255),
IN vAgencyModeFk INT,
OUT vNewTravelFk INT,
OUT vXTx BOOLEAN )
OUT vNewTravelFk INT)
BEGIN
/**
* Clona un travel junto con sus entradas y compras
@ -43,7 +42,6 @@ BEGIN
RESIGNAL;
END;
-- START TRANSACTION;
CALL util.tx_start(vTx);
INSERT INTO travel (shipped, landed, warehouseInFk, warehouseOutFk, agencyModeFk, `ref`, isDelivered, isReceived, m3, cargoSupplierFk, kg,clonedFrom)
@ -66,13 +64,8 @@ BEGIN
LEAVE l;
END IF;
-- CALL util.tx_start(vTx);
CALL entry_cloneHeader(vAuxEntryFk, vNewEntryFk, vNewTravelFk);
-- CALL util.tx_commit(vTx);
-- CALL util.tx_start(vTx);
CALL entry_copyBuys(vAuxEntryFk, vNewEntryFk);
-- CALL util.tx_commit(vTx);
SELECT evaNotes INTO vEvaNotes
FROM entry
@ -87,8 +80,6 @@ BEGIN
SET @isModeInventory = FALSE;
CLOSE vRsEntry;
-- COMMIT;
SET vXTx = vTx;
CALL util.tx_commit(vTx);
END$$
DELIMITER ;

View File

@ -28,6 +28,7 @@ module.exports = Self => {
const conn = Self.dataSource.connector;
const myOptions = {};
let tx = options?.transaction;
try {
if (typeof options == 'object')
Object.assign(myOptions, options);
@ -36,8 +37,7 @@ module.exports = Self => {
tx = await Self.beginTransaction({});
myOptions.transaction = tx;
}
if (myOptions.transaction !== tx)
throw new Error('transaction ID not match');
const travel = await Self.findById(id, {
fields: [
'id',
@ -58,7 +58,7 @@ module.exports = Self => {
let stmts = [];
let stmt;
stmt = new ParameterizedSQL(
`CALL travel_cloneWithEntries(?, ?, ?, ?, ?, ?, ?, @vTravelFk, @vNewTx)`, [
`CALL travel_cloneWithEntries(?, ?, ?, ?, ?, ?, ?, @vTravelFk)`, [
id,
started,
ended,
@ -73,8 +73,6 @@ module.exports = Self => {
const sql = ParameterizedSQL.join(stmts, ';');
const result = await conn.executeStmt(sql, myOptions);
// if (tx) await tx.commit();
const [lastInsert] = result[newTravelIndex];
if (!lastInsert.id)

View File

@ -22,23 +22,16 @@ fdescribe('Travel cloneWithEntries()', () => {
const newTravel = await models.Travel.findById(travelId);
expect(newTravelId).not.toEqual(travelId);
expect(newTravel.ref).toEqual('fifth travel');
expect(newTravel.warehouseInFk).toEqual(warehouseThree);
expect(newTravel.warehouseOutFk).toEqual(warehouseThree);
expect(newTravel.agencyModeFk).toEqual(agencyModeOne);
expect(travelEntries.length).toBeGreaterThan(0);
await tx.rollback();
const travelRemoved = await models.Travel.findById(newTravelId, options);
expect(travelRemoved).toBeNull();
// await models.Entry.destroyAll({
// travelFk: newTravelId
// }, options);
// await models.Travel.destroyById(newTravelId, options);
} catch (e) {
if (tx) await tx.rollback();
throw e;