-
Notifications
You must be signed in to change notification settings - Fork 69
Draft: #645 added run_at_time_zone field to chain and add_job #646
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
gaslitbytech
wants to merge
3
commits into
cybertec-postgresql:master
from
gaslitbytech:645-add-time-zone-per-chain
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -144,7 +144,7 @@ COMMENT ON DOMAIN timetable.cron IS 'Extended CRON-style notation with support o | |
| -- is_cron_in_time returns TRUE if timestamp is listed in cron expression | ||
| CREATE OR REPLACE FUNCTION timetable.is_cron_in_time( | ||
| run_at timetable.cron, | ||
| ts timestamptz | ||
| ts timestamp | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| ) RETURNS BOOLEAN AS $$ | ||
| SELECT | ||
| CASE WHEN run_at IS NULL THEN | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| CREATE OR REPLACE FUNCTION timetable.is_cron_in_time( | ||
| run_at timetable.cron, | ||
| ts timestamp | ||
| ) RETURNS BOOLEAN AS $$ | ||
| SELECT | ||
| CASE WHEN run_at IS NULL THEN | ||
| TRUE | ||
| ELSE | ||
| date_part('month', ts) = ANY(a.months) | ||
| AND (date_part('dow', ts) = ANY(a.dow) OR date_part('isodow', ts) = ANY(a.dow)) | ||
| AND date_part('day', ts) = ANY(a.days) | ||
| AND date_part('hour', ts) = ANY(a.hours) | ||
| AND date_part('minute', ts) = ANY(a.mins) | ||
| END | ||
| FROM | ||
| timetable.cron_split_to_arrays(run_at) a | ||
| $$ LANGUAGE SQL; | ||
|
|
||
| DROP FUNCTION timetable.is_cron_in_time(timetable.cron, timestamp with time zone); | ||
|
|
||
| ALTER TABLE timetable.chain | ||
| ADD COLUMN run_at_time_zone TEXT DEFAULT current_setting('TIMEZONE') NOT NULL; | ||
|
|
||
| CREATE OR REPLACE FUNCTION timetable.add_job( | ||
| job_name TEXT, | ||
| job_schedule timetable.cron, | ||
| job_command TEXT, | ||
| job_parameters JSONB DEFAULT NULL, | ||
| job_kind timetable.command_kind DEFAULT 'SQL'::timetable.command_kind, | ||
| job_client_name TEXT DEFAULT NULL, | ||
| job_max_instances INTEGER DEFAULT NULL, | ||
| job_live BOOLEAN DEFAULT TRUE, | ||
| job_self_destruct BOOLEAN DEFAULT FALSE, | ||
| job_ignore_errors BOOLEAN DEFAULT TRUE, | ||
| job_exclusive BOOLEAN DEFAULT FALSE, | ||
| job_on_error TEXT DEFAULT NULL, | ||
| job_time_zone TEXT DEFAULT current_setting('TIMEZONE') | ||
| ) RETURNS BIGINT AS $$ | ||
| WITH | ||
| cte_chain (v_chain_id) AS ( | ||
| INSERT INTO timetable.chain (chain_name, run_at, max_instances, live, self_destruct, client_name, exclusive_execution, on_error, run_at_time_zone) | ||
| VALUES (job_name, job_schedule,job_max_instances, job_live, job_self_destruct, job_client_name, job_exclusive, job_on_error, job_time_zone) | ||
| RETURNING chain_id | ||
| ), | ||
| cte_task(v_task_id) AS ( | ||
| INSERT INTO timetable.task (chain_id, task_order, kind, command, ignore_error, autonomous) | ||
| SELECT v_chain_id, 10, job_kind, job_command, job_ignore_errors, TRUE | ||
| FROM cte_chain | ||
| RETURNING task_id | ||
| ), | ||
| cte_param AS ( | ||
| INSERT INTO timetable.parameter (task_id, order_id, value) | ||
| SELECT v_task_id, 1, job_parameters FROM cte_task, cte_chain | ||
| ) | ||
| SELECT v_chain_id FROM cte_chain | ||
| $$ LANGUAGE SQL; | ||
|
|
||
| DROP FUNCTION timetable.add_job(TEXT, timetable.cron, TEXT, JSONB, timetable.command_kind, TEXT, INTEGER, BOOLEAN, BOOLEAN, BOOLEAN, BOOLEAN, TEXT); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.