Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 1792a38

Browse files
author
Vladimir Ershov
committed
fix for date
1 parent c0f74cd commit 1792a38

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

pgpro_scheduler--2.0.sql

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -405,8 +405,11 @@ DECLARE
405405
clean_cron jsonb;
406406
N integer;
407407
name text;
408+
updatePrev boolean;
408409
BEGIN
409410

411+
updatePrev := true;
412+
410413
IF NOT params?'cron' AND NOT params?'rule' AND NOT params?'date' AND NOT params?'dates' THEN
411414
RAISE EXCEPTION 'There is no information about job''s schedule'
412415
USING HINT = 'Use ''cron'' - cron string, ''rule'' - json to set schedule rules or ''date'' and ''dates'' to set exact date(s)';
@@ -416,13 +419,11 @@ BEGIN
416419
EXECUTE 'SELECT cron2jsontext($1::cstring)::jsonb'
417420
INTO cron
418421
USING params->>'cron';
419-
IF prev IS NOT NULL THEN
420-
cron := prev || cron;
421-
END IF;
422422
END IF;
423423

424424
IF params?'rule' THEN
425425
rule := params->'rule';
426+
updatePrev := false;
426427
END IF;
427428

428429
cron := coalesce(cron, '{}'::jsonb) || coalesce(rule, '{}'::jsonb);
@@ -448,6 +449,10 @@ BEGIN
448449
cron := cron || jsonb_build_object('dates', array_to_json(dates));
449450
END IF;
450451

452+
IF updatePrev AND prev IS NOT NULL THEN
453+
cron := prev || cron;
454+
END IF;
455+
451456
clean_cron := '{}'::jsonb;
452457
FOR name IN SELECT * FROM unnest('{dates, crontab, onstart, days, hours, wdays, months, minutes}'::text[])
453458
LOOP

0 commit comments

Comments
 (0)