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 $$
CREATE EVENT IF NOT EXISTS `zone_getCollisions`
ON SCHEDULE EVERY 1 DAY
STARTS CURRENT_TIMESTAMP + INTERVAL 1 DAY
ENABLE
DO BEGIN
CALL `zone_getCollisions`();
-- Desactivar el evento después de ejecutarse
ALTER EVENT `zone_getCollisions` DISABLE;
END$$
DELIMITER ;

View File

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

View File

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

View File

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

View File

@ -4,6 +4,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_beforeUp
FOR EACH ROW
BEGIN
SET NEW.editorFk = account.myUser_getId();
-- Activo el evento 'zone_getCollisions'
UPDATE mysql.event SET status = 1 WHERE name = 'zone_getCollisions';
END$$
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 {
const options = {transaction: tx};
await models.Zone.deleteZone(ctx, zoneId, options);
const updatedZone = await models.Zone.findById(zoneId, null, options);