Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc0f74cd

Browse files
author
Vladimir Ershov
committed
fix onstart && cron
1 parent861c85a commitc0f74cd

File tree

1 file changed

+24
-16
lines changed

1 file changed

+24
-16
lines changed

‎pgpro_scheduler--2.0.sql

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -396,34 +396,42 @@ END
396396
$BODY$
397397
LANGUAGE plpgsqlset search_pathFROM CURRENT;
398398

399-
CREATEFUNCTION_get_cron_from_attrs(params jsonb) RETURNS jsonbAS
399+
CREATEFUNCTION_get_cron_from_attrs(params jsonb, prev jsonb) RETURNS jsonbAS
400400
$BODY$
401401
DECLARE
402402
datestext[];
403403
cron jsonb;
404+
rule jsonb;
404405
clean_cron jsonb;
405406
Ninteger;
406407
nametext;
407408
BEGIN
408409

410+
IF NOT params?'cron'AND NOT params?'rule'AND NOT params?'date'AND NOT params?'dates' THEN
411+
RAISE EXCEPTION'There is no information about job''s schedule'
412+
USING HINT='Use''cron'' - cron string,''rule'' - json to set schedule rules or''date'' and''dates'' to set exact date(s)';
413+
END IF;
414+
409415
IF params?'cron' THEN
410416
EXECUTE'SELECT cron2jsontext($1::cstring)::jsonb'
411417
INTO cron
412418
USING params->>'cron';
413-
ELSIF params?'rule' THEN
414-
cron := params->'rule';
415-
ELSIF NOT params?'date'AND NOT params?'dates' THEN
416-
RAISE EXCEPTION'There is no information about job''s schedule'
417-
USING HINT='Use''cron'' - cron string,''rule'' - json to set schedule rules or''date'' and''dates'' to set exact date(s)';
419+
IF prevIS NOT NULL THEN
420+
cron := prev|| cron;
421+
END IF;
418422
END IF;
419423

420-
IF cronIS NOT NULL THEN
421-
IF cron?'date' THEN
422-
dates := _get_array_from_jsonb(dates, cron->'date');
423-
END IF;
424-
IF cron?'dates' THEN
425-
dates := _get_array_from_jsonb(dates, cron->'dates');
426-
END IF;
424+
IF params?'rule' THEN
425+
rule := params->'rule';
426+
END IF;
427+
428+
cron := coalesce(cron,'{}'::jsonb)|| coalesce(rule,'{}'::jsonb);
429+
430+
IF cron?'date' THEN
431+
dates := _get_array_from_jsonb(dates, cron->'date');
432+
END IF;
433+
IF cron?'dates' THEN
434+
dates := _get_array_from_jsonb(dates, cron->'dates');
427435
END IF;
428436

429437
IF params?'date' THEN
@@ -437,7 +445,7 @@ BEGIN
437445
IF N>0 THEN
438446
EXECUTE'SELECT array_agg(lll) FROM (SELECT distinct(date_trunc(''min'', unnest::timestamp with time zone)) as lll FROM unnest($1) ORDER BY date_trunc(''min'', unnest::timestamp with time zone)) as Z'
439447
INTO dates USING dates;
440-
cron :=COALESCE(cron,'{}'::jsonb)|| jsonb_build_object('dates', array_to_json(dates));
448+
cron := cron|| jsonb_build_object('dates', array_to_json(dates));
441449
END IF;
442450

443451
clean_cron :='{}'::jsonb;
@@ -564,7 +572,7 @@ BEGIN
564572
RAISE WARNING'You used excess keys in params: %.', array_to_string(excess,',');
565573
END IF;
566574

567-
cron := _get_cron_from_attrs(params);
575+
cron := _get_cron_from_attrs(params,NULL);
568576
commands := _get_commands_from_attrs(params);
569577
executor := _get_executor_from_attrs(params);
570578
node :='master';
@@ -711,7 +719,7 @@ BEGIN
711719

712720
IF attrs?'cron'OR attrs?'date'OR attrs?'dates'OR attrs?'rule' THEN
713721
cmd := cmd||'rule ='||
714-
quote_literal(_get_cron_from_attrs(attrs))||'::jsonb,';
722+
quote_literal(_get_cron_from_attrs(attrs,job.rule))||'::jsonb,';
715723
END IF;
716724

717725
IF attrs?'command'OR attrs?'commands' THEN

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp