refs #5858 feat: comments
gitea/salix/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Javier Segarra 2024-02-12 11:37:08 +01:00
parent 7f1e3c66e2
commit 0a398fdd6c
7 changed files with 27 additions and 9 deletions

View File

@ -1,11 +1,11 @@
DELIMITER $$ DELIMITER $$
CREATE EVENT IF NOT EXISTS `zone_getCollisions` CREATE EVENT IF NOT EXISTS `zone_getCollisions`
ON SCHEDULE EVERY 1 DAY ON SCHEDULE EVERY 1 DAY
STARTS CURRENT_TIMESTAMP + INTERVAL 1 DAY STARTS CURRENT_TIMESTAMP + INTERVAL 1 DAY
ENABLE
DO BEGIN DO BEGIN
CALL `zone_getCollisions`(); CALL `zone_getCollisions`();
-- Desactivar el evento después de ejecutarse
ALTER EVENT `zone_getCollisions` DISABLE; ALTER EVENT `zone_getCollisions` DISABLE;
END$$ END$$
DELIMITER;
DELIMITER ;

View File

@ -1,5 +1,6 @@
DELIMITER $$ DELIMITER $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zoneIncluded_checkCollisions`()
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zone_getCollisions`()
BEGIN BEGIN
/** /**
* Calcula si para un mismo codigo postal y dia * Calcula si para un mismo codigo postal y dia
@ -78,6 +79,7 @@ BEGIN
GROUP BY z.agencyModeFk, zn.geoFk, zw.warehouseFk GROUP BY z.agencyModeFk, zn.geoFk, zw.warehouseFk
HAVING count(*) > 1; HAVING count(*) > 1;
-- Recojo los datos de la zona que ha dado conflicto
SELECT JSON_ARRAYAGG( SELECT JSON_ARRAYAGG(
JSON_OBJECT( JSON_OBJECT(
'zoneFk', zoneFk, 'zoneFk', zoneFk,
@ -91,6 +93,7 @@ BEGIN
JOIN warehouse w ON w.id = gc.warehouseFk JOIN warehouse w ON w.id = gc.warehouseFk
INTO json_data; INTO json_data;
-- Creo un registro de la notificacion 'zone-included' para reportar via email
SELECT util.notification_send( SELECT util.notification_send(
'zone-included', 'zone-included',
JSON_OBJECT('zoneCollisions',json_data), JSON_OBJECT('zoneCollisions',json_data),
@ -101,5 +104,5 @@ BEGIN
geoCollision, geoCollision,
tmp.zone, tmp.zone,
tmp.zoneNodes; tmp.zoneNodes;
END ;; END$$
DELIMITER ; DELIMITER ;

View File

@ -8,6 +8,8 @@ BEGIN
`changedModel` = 'zoneIncluded', `changedModel` = 'zoneIncluded',
`changedModelId` = OLD.zoneFk, `changedModelId` = OLD.zoneFk,
`userFk` = account.myUser_getId(); `userFk` = account.myUser_getId();
-- Activo el evento 'zone_getCollisions'
UPDATE mysql.event SET status = 1 WHERE name = 'zone_getCollisions'; UPDATE mysql.event SET status = 1 WHERE name = 'zone_getCollisions';
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -4,6 +4,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_beforeIn
FOR EACH ROW FOR EACH ROW
BEGIN BEGIN
SET NEW.editorFk = account.myUser_getId(); SET NEW.editorFk = account.myUser_getId();
-- Activo el evento 'zone_getCollisions'
UPDATE mysql.event SET status = 1 WHERE name = 'zone_getCollisions'; UPDATE mysql.event SET status = 1 WHERE name = 'zone_getCollisions';
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -4,6 +4,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_beforeUp
FOR EACH ROW FOR EACH ROW
BEGIN BEGIN
SET NEW.editorFk = account.myUser_getId(); SET NEW.editorFk = account.myUser_getId();
-- Activo el evento 'zone_getCollisions'
UPDATE mysql.event SET status = 1 WHERE name = 'zone_getCollisions'; UPDATE mysql.event SET status = 1 WHERE name = 'zone_getCollisions';
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -0,0 +1,10 @@
INSERT INTO util.notification (id, name,description)
VALUES (
(SELECT MAX(id)+1 from util.notification n) , 'zone-included','An email to notify zoneCollisions');
INSERT INTO util.notificationSubscription (notificationFk,userFk)
SELECT id, account.myUser_getId() FROM util.notification WHERE name= "zone-included";
INSERT INTO util.notificationAcl (notificationFk,roleFk)
SELECT id, (SELECT id from `account`.`role` where name = "system") FROM util.notification WHERE name= "zone-included";

View File

@ -35,7 +35,6 @@ describe('zone deletezone()', () => {
try { try {
const options = {transaction: tx}; const options = {transaction: tx};
await models.Zone.deleteZone(ctx, zoneId, options); await models.Zone.deleteZone(ctx, zoneId, options);
const updatedZone = await models.Zone.findById(zoneId, null, options); const updatedZone = await models.Zone.findById(zoneId, null, options);