diff --git a/db/dump/fixtures.after.sql b/db/dump/fixtures.after.sql index 2b83cca57..c539b2aab 100644 --- a/db/dump/fixtures.after.sql +++ b/db/dump/fixtures.after.sql @@ -325,6 +325,4 @@ INSERT INTO mysql.roles_mapping (`User`, `Host`, `Role`, `Admin_option`) WHERE `User` LIKE @prefixedLike AND `Host` = @genRoleHost; -TRUNCATE util.vn_schedules; - FLUSH PRIVILEGES; diff --git a/db/routines/util/events/vn_scheduler.sql b/db/routines/util/events/vn_scheduler.sql deleted file mode 100644 index 2d8457499..000000000 --- a/db/routines/util/events/vn_scheduler.sql +++ /dev/null @@ -1,14 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `VN_SCHEDULER` - ON SCHEDULE EVERY 1 DAY - STARTS CURRENT_TIMESTAMP + INTERVAL 1 DAY - ENABLE - DO BEGIN - /** - * Ejecuta el PROCEDURE que comprueba si hay procedimientos planificados para ejecutar - * - */ - CALL `VN_SCHEDULER`(); - END$$ - -DELIMITER ; diff --git a/db/routines/util/procedures/vn_scheduler.sql b/db/routines/util/procedures/vn_scheduler.sql deleted file mode 100644 index cd7c629f8..000000000 --- a/db/routines/util/procedures/vn_scheduler.sql +++ /dev/null @@ -1,67 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`VN_SCHEDULER`() -BEGIN -/** - * Ejecuta los procedimientos que se han programado a demanda. - * -*/ - DECLARE vDone BOOL; - DECLARE vError VARCHAR(255) DEFAULT NULL; - DECLARE vErrorCode VARCHAR(255) DEFAULT NULL; - DECLARE vSchema VARCHAR(255); - DECLARE vStatus VARCHAR(255); - DECLARE vProcedure VARCHAR(255); - - DECLARE vScheduleFk INT; - -- Obtener datos de la tabla vn_schedules - DECLARE vQueue CURSOR FOR - SELECT id, `schema`, `procedure`, `status` - FROM vn_schedules - WHERE status = 'scheduled'; - DECLARE EXIT HANDLER FOR SQLEXCEPTION - GET DIAGNOSTICS CONDITION 1 - vError = MESSAGE_TEXT, - vErrorCode = RETURNED_SQLSTATE; - OPEN vQueue; - l: LOOP - SET vDone = FALSE; - FETCH vQueue INTO vScheduleFk, vSchema, vProcedure, vStatus; - - IF vDone THEN - LEAVE l; - END IF; - - UPDATE vn_schedules - SET `started` = util.VN_NOW(), - `finished` = NULL, - `error` = NULL, - `errorCode` = NULL - WHERE id = vScheduleFk; - - SET vError = NULL; - - - CALL util.exec(CONCAT('CALL `', vSchema ,'`.`', vProcedure ,'`')); - - IF vError IS NOT NULL THEN - UPDATE vn_schedules - SET `error` = vError, - finished = util.VN_NOW(), - lastFinished = util.VN_NOW(), - `errorCode` = vErrorCode, - `status` = 'error' - WHERE id = vScheduleFk; - ELSE - UPDATE vn_schedules - SET `error` = vError, - `errorCode` = vErrorCode, - finished = util.VN_NOW(), - lastFinished = util.VN_NOW(), - `status` = 'exec' - WHERE id = vScheduleFk; - END IF; - END LOOP; - CLOSE vQueue; -END$$ - -DELIMITER ; diff --git a/db/routines/vn/triggers/zoneIncluded_afterDelete.sql b/db/routines/vn/triggers/zoneIncluded_afterDelete.sql index 1a076cd8f..3ff8be421 100644 --- a/db/routines/vn/triggers/zoneIncluded_afterDelete.sql +++ b/db/routines/vn/triggers/zoneIncluded_afterDelete.sql @@ -9,11 +9,6 @@ BEGIN `changedModelId` = OLD.zoneFk, `userFk` = account.myUser_getId(); - -- Inserta en vn_schedules para ejecutar el procedure de 'zone_getCollisions' - - INSERT IGNORE INTO `util`.`vn_schedules`(`schema`, `procedure`) - VALUES - ('vn', 'zone_getCollisions'); END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/zoneIncluded_beforeInsert.sql b/db/routines/vn/triggers/zoneIncluded_beforeInsert.sql index 13d45aa12..18895c9a5 100644 --- a/db/routines/vn/triggers/zoneIncluded_beforeInsert.sql +++ b/db/routines/vn/triggers/zoneIncluded_beforeInsert.sql @@ -5,11 +5,5 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_beforeIn BEGIN SET NEW.editorFk = account.myUser_getId(); - -- Inserta en vn_schedules para ejecutar el procedure de 'zone_getCollisions' - - INSERT IGNORE INTO `util`.`vn_schedules`(`schema`, `procedure`) - VALUES - ('vn', 'zone_getCollisions'); - END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/zoneIncluded_beforeUpdate.sql b/db/routines/vn/triggers/zoneIncluded_beforeUpdate.sql index f54c55654..445f37699 100644 --- a/db/routines/vn/triggers/zoneIncluded_beforeUpdate.sql +++ b/db/routines/vn/triggers/zoneIncluded_beforeUpdate.sql @@ -4,11 +4,5 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_beforeUp FOR EACH ROW BEGIN SET NEW.editorFk = account.myUser_getId(); - - -- Inserta en vn_schedules para ejecutar el procedure de 'zone_getCollisions' - - INSERT IGNORE INTO `util`.`vn_schedules`(`schema`, `procedure`) - VALUES - ('vn', 'zone_getCollisions'); END$$ DELIMITER ; diff --git a/db/versions/10881-greenHydrangea/00-createVnSchedules.sql b/db/versions/10881-greenHydrangea/00-createVnSchedules.sql deleted file mode 100644 index 07dedf7d3..000000000 --- a/db/versions/10881-greenHydrangea/00-createVnSchedules.sql +++ /dev/null @@ -1,14 +0,0 @@ -CREATE TABLE IF NOT EXISTS `util`.`vn_schedules` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `started` datetime DEFAULT NULL, - `finished` datetime DEFAULT NULL, - `lastFinished` datetime DEFAULT NULL, - `order` int(11) DEFAULT NULL, - `schema` varchar(45) NOT NULL, - `procedure` varchar(100) NOT NULL, - `error` varchar(255) DEFAULT NULL, - `errorCode` varchar(10) DEFAULT NULL, - `status` enum('scheduled','exec','error') NOT NULL DEFAULT 'scheduled', - PRIMARY KEY (`id`), - UNIQUE KEY unique_schedule (`schema`, `procedure`, `status`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; diff --git a/modules/zone/back/methods/zone/specs/toggleIsIncluded.spec.js b/modules/zone/back/methods/zone/specs/toggleIsIncluded.spec.js index a7a2a7808..2da176330 100644 --- a/modules/zone/back/methods/zone/specs/toggleIsIncluded.spec.js +++ b/modules/zone/back/methods/zone/specs/toggleIsIncluded.spec.js @@ -20,12 +20,10 @@ describe('zone toggleIsIncluded()', () => { try { const options = {transaction: tx}; - await validateSchedules('before', options); let result = await models.Zone.toggleIsIncluded(1, 20, true, options); expect(result.isIncluded).toBeTrue(); - await validateSchedules('after', options); await tx.rollback(); } catch (e) { @@ -39,12 +37,10 @@ describe('zone toggleIsIncluded()', () => { try { const options = {transaction: tx}; - await validateSchedules('before', options); let result = await models.Zone.toggleIsIncluded(1, 20, false, options); expect(result.isIncluded).toBeFalse(); - await validateSchedules('after', options); await tx.rollback(); } catch (e) { @@ -58,14 +54,13 @@ describe('zone toggleIsIncluded()', () => { try { const options = {transaction: tx}; - await validateSchedules('before', options); + await models.Zone.toggleIsIncluded(1, 20, false, options); const result = await models.Zone.toggleIsIncluded(1, 20, undefined, options); expect(result).toEqual({count: 1}); - await validateSchedules('after', options); await tx.rollback(); } catch (e) { await tx.rollback(); @@ -73,22 +68,3 @@ describe('zone toggleIsIncluded()', () => { } }); }); - -async function validateSchedules(step, options = null) { - const querySchedules = `SELECT count(*) count FROM util.vn_schedules;`; - - switch (step) { - case 'before': { - const [{count}] = await models.Application.rawSql(querySchedules, null, options); - - expect(count).toEqual(0); - } - break; - case 'after': { - const [{count}] = await models.Application.rawSql(querySchedules, null, options); - - expect(count).toEqual(1); - } - break; - } -}