adding begin end dates to instructions

parent 5e8dadf3
...@@ -89,7 +89,9 @@ thisTrigger: BEGIN ...@@ -89,7 +89,9 @@ thisTrigger: BEGIN
NOW(3) NOW(3)
) )
ON DUPLICATE KEY UPDATE id_stu=idstu, id_sup=idsup, id_ws=NEW.id_ws, id_opentry=NEW.id; ON DUPLICATE KEY UPDATE id_stu=idstu, id_sup=idsup, id_ws=NEW.id_ws, id_opentry=NEW.id;
END;; END;;
-- --
-- It deletes current try for a given session -- It deletes current try for a given session
DROP PROCEDURE IF EXISTS deleteOpenTry; DROP PROCEDURE IF EXISTS deleteOpenTry;
...@@ -117,6 +119,7 @@ AFTER INSERT ON working_session ...@@ -117,6 +119,7 @@ AFTER INSERT ON working_session
FOR EACH ROW FOR EACH ROW
thisTrigger: BEGIN thisTrigger: BEGIN
DECLARE idstu INT; DECLARE idstu INT;
DECLARE ins_begin DATE;
IF ((@TRIGGER_CHECKS = FALSE) IF ((@TRIGGER_CHECKS = FALSE)
OR (@TRIGGER_AFTER_INSERT_CHECKS = FALSE)) OR (@TRIGGER_AFTER_INSERT_CHECKS = FALSE))
...@@ -125,9 +128,25 @@ thisTrigger: BEGIN ...@@ -125,9 +128,25 @@ thisTrigger: BEGIN
LEAVE thisTrigger; LEAVE thisTrigger;
END IF; END IF;
UPDATE instruction SELECT begin INTO ins_begin
SET status='started' FROM instruction
WHERE id=new.id_ins; WHERE id = NEW.id_ins
IF (ins_begin IS NULL) THEN
UPDATE instruction
SET
begin = NOW(3),
end = NOW(3)
WHERE
id = NEW.id_ins
END IF;
UPDATE instruction
SET
status='started',
end = NOW(3)
WHERE
id = NEW.id_ins;
INSERT INTO try(`id_ws`) INSERT INTO try(`id_ws`)
VALUES (new.id); VALUES (new.id);
...@@ -150,6 +169,16 @@ thisTrigger: BEGIN ...@@ -150,6 +169,16 @@ thisTrigger: BEGIN
LEAVE thisTrigger; LEAVE thisTrigger;
END IF; END IF;
-- end date for related instruction is updated
IF (OLD.end < NEW.end) THEN
UPDATE instruction
SET
end = NEW.end
WHERE
id = NEW.id_ins
END IF;
-- remove open try
IF ((old.end IS NULL) and (new.end IS NOT NULL)) THEN IF ((old.end IS NULL) and (new.end IS NOT NULL)) THEN
CALL deleteOpenTry(new.id); CALL deleteOpenTry(new.id);
END IF; END IF;
...@@ -335,6 +364,8 @@ thisTrigger: BEGIN ...@@ -335,6 +364,8 @@ thisTrigger: BEGIN
WHERE id = NEW.id_ws; WHERE id = NEW.id_ws;
END IF; END IF;
END;; END;;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment