feat: add summary to schedules

This commit is contained in:
Ruben Fiszel
2023-12-26 14:15:33 +01:00
parent fe0230da04
commit b290cbb758
33 changed files with 344 additions and 64 deletions
@@ -32,7 +32,6 @@
"noop",
"appdependencies",
"deploymentcallback",
"scheduledscriptwithretry",
"singlescriptflow"
]
}
@@ -49,6 +48,7 @@
"bash",
"postgresql",
"nativets",
"Nativets",
"bun",
"mysql",
"bigquery",
@@ -47,7 +47,6 @@
"noop",
"appdependencies",
"deploymentcallback",
"scheduledscriptwithretry",
"singlescriptflow"
]
}
@@ -70,6 +69,7 @@
"bash",
"postgresql",
"nativets",
"Nativets",
"bun",
"mysql",
"bigquery",
@@ -42,6 +42,7 @@
"bash",
"postgresql",
"nativets",
"Nativets",
"bun",
"mysql",
"bigquery",
@@ -28,6 +28,7 @@
"bash",
"postgresql",
"nativets",
"Nativets",
"bun",
"mysql",
"bigquery",
@@ -42,7 +42,6 @@
"noop",
"appdependencies",
"deploymentcallback",
"scheduledscriptwithretry",
"singlescriptflow"
]
}
@@ -63,6 +62,7 @@
"bash",
"postgresql",
"nativets",
"Nativets",
"bun",
"mysql",
"bigquery",
@@ -37,6 +37,7 @@
"bash",
"postgresql",
"nativets",
"Nativets",
"bun",
"mysql",
"bigquery",
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
"query": "INSERT INTO schedule (workspace_id, path, schedule, timezone, edited_by, script_path, is_flow, args, enabled, email, on_failure, on_failure_times, on_failure_exact, on_failure_extra_args, on_recovery, on_recovery_times, on_recovery_extra_args, ws_error_handler_muted, retry ) VALUES ( $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19 ) RETURNING *",
"query": "INSERT INTO schedule (workspace_id, path, schedule, timezone, edited_by, script_path, is_flow, args, enabled, email, on_failure, on_failure_times, on_failure_exact, on_failure_extra_args, on_recovery, on_recovery_times, on_recovery_extra_args, ws_error_handler_muted, retry, summary, no_flow_overlap ) VALUES ( $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21 ) RETURNING *",
"describe": {
"columns": [
{
@@ -112,6 +112,16 @@
"ordinal": 21,
"name": "retry",
"type_info": "Jsonb"
},
{
"ordinal": 22,
"name": "summary",
"type_info": "Varchar"
},
{
"ordinal": 23,
"name": "no_flow_overlap",
"type_info": "Bool"
}
],
"parameters": {
@@ -134,7 +144,9 @@
"Int4",
"Json",
"Bool",
"Jsonb"
"Jsonb",
"Varchar",
"Bool"
]
},
"nullable": [
@@ -159,8 +171,10 @@
true,
true,
false,
true
true,
true,
false
]
},
"hash": "b53442ca97ed9d25990405281c82c31062de24cbd2f99d1c4039965d861aafa9"
"hash": "6bb9e6cab7034bf28ef2597445dc617b60c49b42568fdb975cf2d2dc8702167e"
}
@@ -115,6 +115,16 @@
},
{
"ordinal": 22,
"name": "summary",
"type_info": "Varchar"
},
{
"ordinal": 23,
"name": "no_flow_overlap",
"type_info": "Bool"
},
{
"ordinal": 24,
"name": "jobs",
"type_info": "JsonArray"
}
@@ -149,6 +159,8 @@
true,
false,
true,
true,
false,
null
]
},
@@ -112,6 +112,16 @@
"ordinal": 21,
"name": "retry",
"type_info": "Jsonb"
},
{
"ordinal": 22,
"name": "summary",
"type_info": "Varchar"
},
{
"ordinal": 23,
"name": "no_flow_overlap",
"type_info": "Bool"
}
],
"parameters": {
@@ -143,7 +153,9 @@
true,
true,
false,
true
true,
true,
false
]
},
"hash": "911b1e1f2a5ba6d5159916e5598020e680c45043b0736ad0153ee261a151dd90"
@@ -112,6 +112,16 @@
"ordinal": 21,
"name": "retry",
"type_info": "Jsonb"
},
{
"ordinal": 22,
"name": "summary",
"type_info": "Varchar"
},
{
"ordinal": 23,
"name": "no_flow_overlap",
"type_info": "Bool"
}
],
"parameters": {
@@ -144,7 +154,9 @@
true,
true,
false,
true
true,
true,
false
]
},
"hash": "96dc1cd308f3c21cfb50b88048054dc03f93e261d25969d66aa48e9d0502960f"
@@ -26,7 +26,6 @@
"noop",
"appdependencies",
"deploymentcallback",
"scheduledscriptwithretry",
"singlescriptflow"
]
}
@@ -43,6 +42,7 @@
"bash",
"postgresql",
"nativets",
"Nativets",
"bun",
"mysql",
"bigquery",
@@ -112,6 +112,16 @@
"ordinal": 21,
"name": "retry",
"type_info": "Jsonb"
},
{
"ordinal": 22,
"name": "summary",
"type_info": "Varchar"
},
{
"ordinal": 23,
"name": "no_flow_overlap",
"type_info": "Bool"
}
],
"parameters": {
@@ -142,7 +152,9 @@
true,
true,
false,
true
true,
true,
false
]
},
"hash": "aa2800113a8a8805f47cdc1dd0f29d94c546fe531e7edd3e91da4978af5442fb"
@@ -42,6 +42,7 @@
"bash",
"postgresql",
"nativets",
"Nativets",
"bun",
"mysql",
"bigquery",
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
"query": "UPDATE schedule SET schedule = $1, timezone = $2, args = $3, on_failure = $4, on_failure_times = $5, on_failure_exact = $6, on_failure_extra_args = $7, on_recovery = $8, on_recovery_times = $9, on_recovery_extra_args = $10, ws_error_handler_muted = $11, retry = $12\n WHERE path = $13 AND workspace_id = $14 RETURNING *",
"query": "UPDATE schedule SET schedule = $1, timezone = $2, args = $3, on_failure = $4, on_failure_times = $5, on_failure_exact = $6, on_failure_extra_args = $7, on_recovery = $8, on_recovery_times = $9, on_recovery_extra_args = $10, ws_error_handler_muted = $11, retry = $12, summary = $13, no_flow_overlap = $14 WHERE path = $15 AND workspace_id = $16 RETURNING *",
"describe": {
"columns": [
{
@@ -112,6 +112,16 @@
"ordinal": 21,
"name": "retry",
"type_info": "Jsonb"
},
{
"ordinal": 22,
"name": "summary",
"type_info": "Varchar"
},
{
"ordinal": 23,
"name": "no_flow_overlap",
"type_info": "Bool"
}
],
"parameters": {
@@ -128,6 +138,8 @@
"Json",
"Bool",
"Jsonb",
"Varchar",
"Bool",
"Text",
"Text"
]
@@ -154,8 +166,10 @@
true,
true,
false,
true
true,
true,
false
]
},
"hash": "e1673b211da54039c5cffa5a38fe23073149bc5bfcea1daccb657d5fa6892183"
"hash": "b7ed211ec7611c994a49565e46e5893788bcf49b2c9357fbc45a8353a7c84f48"
}
@@ -112,6 +112,16 @@
"ordinal": 21,
"name": "retry",
"type_info": "Jsonb"
},
{
"ordinal": 22,
"name": "summary",
"type_info": "Varchar"
},
{
"ordinal": 23,
"name": "no_flow_overlap",
"type_info": "Bool"
}
],
"parameters": {
@@ -143,7 +153,9 @@
true,
true,
false,
true
true,
true,
false
]
},
"hash": "c10348d26e3e3dc9e345d9044db35db9906617eb9c98aaf58a55d9681ffb85e3"
@@ -112,6 +112,16 @@
"ordinal": 21,
"name": "retry",
"type_info": "Jsonb"
},
{
"ordinal": 22,
"name": "summary",
"type_info": "Varchar"
},
{
"ordinal": 23,
"name": "no_flow_overlap",
"type_info": "Bool"
}
],
"parameters": {
@@ -143,7 +153,9 @@
true,
true,
false,
true
true,
true,
false
]
},
"hash": "dd74fa9468b5fe8c8ad657ded06076c11a78d0206af2af20685c691d4d9520bb"
@@ -112,6 +112,16 @@
"ordinal": 21,
"name": "retry",
"type_info": "Jsonb"
},
{
"ordinal": 22,
"name": "summary",
"type_info": "Varchar"
},
{
"ordinal": 23,
"name": "no_flow_overlap",
"type_info": "Bool"
}
],
"parameters": {
@@ -143,7 +153,9 @@
true,
true,
false,
true
true,
true,
false
]
},
"hash": "eced0a09ba547ce1dccb54a5419b22373603c9d01f77047b3553bde125bf71e8"
@@ -42,6 +42,7 @@
"bash",
"postgresql",
"nativets",
"Nativets",
"bun",
"mysql",
"bigquery",
@@ -41,7 +41,6 @@
"noop",
"appdependencies",
"deploymentcallback",
"scheduledscriptwithretry",
"singlescriptflow"
]
}
@@ -66,7 +65,6 @@
"noop",
"appdependencies",
"deploymentcallback",
"scheduledscriptwithretry",
"singlescriptflow"
]
}
@@ -112,6 +112,16 @@
"ordinal": 21,
"name": "retry",
"type_info": "Jsonb"
},
{
"ordinal": 22,
"name": "summary",
"type_info": "Varchar"
},
{
"ordinal": 23,
"name": "no_flow_overlap",
"type_info": "Bool"
}
],
"parameters": {
@@ -141,7 +151,9 @@
true,
true,
false,
true
true,
true,
false
]
},
"hash": "fdd3710a381dac33ef5ee5ec5564a4874e6d7807d43fa6ea7b8408cad9e97480"
@@ -0,0 +1 @@
-- Add down migration script here
@@ -0,0 +1,3 @@
-- Add up migration script here
ALTER TABLE schedule ADD COLUMN summary VARCHAR(512);
ALTER TABLE schedule ADD COLUMN no_flow_overlap BOOLEAN NOT NULL DEFAULT FALSE;
+9
View File
@@ -2871,6 +2871,9 @@ async fn test_script_schedule_handlers(db: Pool<Postgres>) {
schedule: format!("{} {} * * * *", then.second(), then.minute()).to_string(),
ws_error_handler_muted: None,
retry: None,
no_flow_overlap: None,
summary: None,
};
let _ = client.create_schedule("test-workspace", &schedule).await;
@@ -2932,6 +2935,8 @@ async fn test_script_schedule_handlers(db: Pool<Postgres>) {
schedule: format!("{} {} * * * *", then.second(), then.minute()).to_string(),
ws_error_handler_muted: None,
retry: None,
summary: None,
no_flow_overlap: None
},
)
.await
@@ -3009,6 +3014,8 @@ async fn test_flow_schedule_handlers(db: Pool<Postgres>) {
schedule: format!("{} {} * * * *", then.second(), then.minute()).to_string(),
ws_error_handler_muted: None,
retry: None,
no_flow_overlap: None,
summary: None,
};
let _ = client.create_schedule("test-workspace", &schedule).await;
@@ -3071,6 +3078,8 @@ async fn test_flow_schedule_handlers(db: Pool<Postgres>) {
schedule: format!("{} {} * * * *", then.second(), then.minute()).to_string(),
ws_error_handler_muted: None,
retry: None,
summary: None,
no_flow_overlap: None
},
)
.await
+62 -24
View File
@@ -2231,7 +2231,8 @@ paths:
/w/{workspace}/resources/get_value_interpolated/{path}:
get:
summary: get resource interpolated (variables and resources are fully unrolled)
summary:
get resource interpolated (variables and resources are fully unrolled)
operationId: getResourceValueInterpolated
tags:
- resource
@@ -2919,7 +2920,8 @@ paths:
schema:
type: string
- name: first_parent_hash
description: mask to filter scripts whom first direct parent has exact hash
description:
mask to filter scripts whom first direct parent has exact hash
in: query
schema:
type: string
@@ -3114,7 +3116,8 @@ paths:
/workers/custom_tags:
get:
summary: get all instance custom tags (tags are used to dispatch jobs to
summary:
get all instance custom tags (tags are used to dispatch jobs to
different worker groups)
operationId: getCustomTags
tags:
@@ -3165,7 +3168,8 @@ paths:
/w/{workspace}/scripts/delete/h/{hash}:
post:
summary: delete script by hash (erase content but keep hash, require admin)
summary:
delete script by hash (erase content but keep hash, require admin)
operationId: deleteScriptByHash
tags:
- script
@@ -3404,7 +3408,8 @@ paths:
type: string
format: date-time
- name: scheduled_in_secs
description: schedule the script to execute in the number of seconds starting now
description:
schedule the script to execute in the number of seconds starting now
in: query
schema:
type: integer
@@ -3412,7 +3417,8 @@ paths:
- $ref: "#/components/parameters/WorkerTag"
- $ref: "#/components/parameters/NewJobId"
- name: invisible_to_owner
description: make the run invisible to the the script owner (default false)
description:
make the run invisible to the the script owner (default false)
in: query
schema:
type: boolean
@@ -4445,7 +4451,8 @@ paths:
type: string
format: date-time
- name: scheduled_in_secs
description: schedule the script to execute in the number of seconds starting now
description:
schedule the script to execute in the number of seconds starting now
in: query
schema:
type: integer
@@ -4454,7 +4461,8 @@ paths:
- $ref: "#/components/parameters/NewJobId"
- $ref: "#/components/parameters/IncludeHeader"
- name: invisible_to_owner
description: make the run invisible to the the flow owner (default false)
description:
make the run invisible to the the flow owner (default false)
in: query
schema:
type: boolean
@@ -4506,7 +4514,8 @@ paths:
type: string
format: date-time
- name: scheduled_in_secs
description: schedule the script to execute in the number of seconds starting now
description:
schedule the script to execute in the number of seconds starting now
in: query
schema:
type: integer
@@ -4515,7 +4524,8 @@ paths:
- $ref: "#/components/parameters/NewJobId"
- $ref: "#/components/parameters/IncludeHeader"
- name: invisible_to_owner
description: make the run invisible to the the flow owner (default false)
description:
make the run invisible to the the flow owner (default false)
in: query
schema:
type: boolean
@@ -4553,7 +4563,8 @@ paths:
type: string
format: date-time
- name: scheduled_in_secs
description: schedule the script to execute in the number of seconds starting now
description:
schedule the script to execute in the number of seconds starting now
in: query
schema:
type: integer
@@ -4562,7 +4573,8 @@ paths:
- $ref: "#/components/parameters/NewJobId"
- $ref: "#/components/parameters/IncludeHeader"
- name: invisible_to_owner
description: make the run invisible to the the script owner (default false)
description:
make the run invisible to the the script owner (default false)
in: query
schema:
type: boolean
@@ -4593,7 +4605,8 @@ paths:
- $ref: "#/components/parameters/WorkspaceId"
- $ref: "#/components/parameters/IncludeHeader"
- name: invisible_to_owner
description: make the run invisible to the the script owner (default false)
description:
make the run invisible to the the script owner (default false)
in: query
schema:
type: boolean
@@ -4626,7 +4639,8 @@ paths:
- $ref: "#/components/parameters/WorkspaceId"
- $ref: "#/components/parameters/IncludeHeader"
- name: invisible_to_owner
description: make the run invisible to the the script owner (default false)
description:
make the run invisible to the the script owner (default false)
in: query
schema:
type: boolean
@@ -4843,7 +4857,8 @@ paths:
- job
responses:
"200":
description: the timestamp of the db that can be used to compute the drift
description:
the timestamp of the db that can be used to compute the drift
content:
application/json:
schema:
@@ -5107,7 +5122,8 @@ paths:
/w/{workspace}/jobs/resume_urls/{id}/{resume_id}:
get:
summary: get resume urls given a job_id, resume_id and a nonce to resume a flow
summary:
get resume urls given a job_id, resume_id and a nonce to resume a flow
operationId: getResumeUrls
tags:
- job
@@ -5658,7 +5674,8 @@ paths:
- $ref: "#/components/parameters/WorkspaceId"
- name: only_member_of
in: query
description: only list the groups the user is member of (default false)
description:
only list the groups the user is member of (default false)
schema:
type: boolean
responses:
@@ -5846,7 +5863,8 @@ paths:
- $ref: "#/components/parameters/WorkspaceId"
- name: only_member_of
in: query
description: only list the folders the user is member of (default false)
description:
only list the folders the user is member of (default false)
schema:
type: boolean
responses:
@@ -6674,14 +6692,18 @@ paths:
- storage_options
/w/{workspace}/job_helpers/v2/s3_resource_info:
post:
summary: Returns the s3 resource associated to the provided path, or the workspace default S3 resource
summary:
Returns the s3 resource associated to the provided path, or the
workspace default S3 resource
operationId: s3ResourceInfo
tags:
- helpers
parameters:
- $ref: "#/components/parameters/WorkspaceId"
requestBody:
description: S3 resource path to use. If empty, the S3 resource defined in the workspace settings will be used
description:
S3 resource path to use. If empty, the S3 resource defined in the
workspace settings will be used
required: true
content:
application/json:
@@ -7015,7 +7037,8 @@ components:
type: integer
PerPage:
name: per_page
description: number of items to return for a given page (default 30, max 100)
description:
number of items to return for a given page (default 30, max 100)
in: query
schema:
type: integer
@@ -7143,7 +7166,8 @@ components:
type: boolean
ScheduledForBeforeNow:
name: scheduled_for_before_now
description: filter on jobs scheduled_for before now (hence waitinf for a worker)
description:
filter on jobs scheduled_for before now (hence waitinf for a worker)
in: query
schema:
type: boolean
@@ -7161,7 +7185,8 @@ components:
type: boolean
ArgsFilter:
name: args
description: filter on jobs containing those args as a json subset (@> in postgres)
description:
filter on jobs containing those args as a json subset (@> in postgres)
in: query
schema:
type: string
@@ -7173,7 +7198,8 @@ components:
type: string
ResultFilter:
name: result
description: filter on jobs containing those result as a json subset (@> in postgres)
description:
filter on jobs containing those result as a json subset (@> in postgres)
in: query
schema:
type: string
@@ -8399,6 +8425,10 @@ components:
type: boolean
retry:
$ref: "../../openflow.openapi.yaml#/components/schemas/Retry"
summary:
type: string
no_flow_overlap:
type: boolean
required:
- path
- edited_by
@@ -8468,6 +8498,10 @@ components:
type: boolean
retry:
$ref: "../../openflow.openapi.yaml#/components/schemas/Retry"
no_flow_overlap:
type: boolean
summary:
type: string
required:
- path
- schedule
@@ -8504,6 +8538,10 @@ components:
type: boolean
retry:
$ref: "../../openflow.openapi.yaml#/components/schemas/Retry"
no_flow_overlap:
type: boolean
summary:
type: string
required:
- schedule
- timezone
+14 -4
View File
@@ -54,6 +54,8 @@ pub struct NewSchedule {
pub path: String,
pub schedule: String,
pub timezone: String,
pub summary: Option<String>,
pub no_flow_overlap: Option<bool>,
pub script_path: String,
pub is_flow: bool,
pub args: Option<serde_json::Value>,
@@ -153,9 +155,9 @@ async fn create_schedule(
"INSERT INTO schedule (workspace_id, path, schedule, timezone, edited_by, script_path, \
is_flow, args, enabled, email, on_failure, on_failure_times, on_failure_exact, \
on_failure_extra_args, on_recovery, on_recovery_times, on_recovery_extra_args, \
ws_error_handler_muted, retry \
ws_error_handler_muted, retry, summary, no_flow_overlap \
) VALUES ( \
$1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19 \
$1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21 \
) RETURNING *",
w_id,
ns.path,
@@ -176,6 +178,8 @@ async fn create_schedule(
ns.on_recovery_extra_args,
ns.ws_error_handler_muted.unwrap_or(false),
ns.retry,
ns.summary,
ns.no_flow_overlap.unwrap_or(false),
)
.fetch_one(&mut tx)
.await
@@ -229,8 +233,8 @@ async fn edit_schedule(
Schedule,
"UPDATE schedule SET schedule = $1, timezone = $2, args = $3, on_failure = $4, on_failure_times = $5, \
on_failure_exact = $6, on_failure_extra_args = $7, on_recovery = $8, on_recovery_times = $9, \
on_recovery_extra_args = $10, ws_error_handler_muted = $11, retry = $12
WHERE path = $13 AND workspace_id = $14 RETURNING *",
on_recovery_extra_args = $10, ws_error_handler_muted = $11, retry = $12, summary = $13, no_flow_overlap = $14 \
WHERE path = $15 AND workspace_id = $16 RETURNING *",
es.schedule,
es.timezone,
es.args,
@@ -243,6 +247,8 @@ async fn edit_schedule(
es.on_recovery_extra_args,
es.ws_error_handler_muted.unwrap_or(false),
es.retry,
es.summary,
es.no_flow_overlap.unwrap_or(false),
path,
w_id,
)
@@ -336,6 +342,8 @@ pub struct ScheduleWJobs {
pub ws_error_handler_muted: bool,
pub retry: Option<serde_json::Value>,
pub jobs: Option<Vec<serde_json::Value>>,
pub summary: Option<String>,
pub no_flow_overlap: bool,
}
async fn list_schedule_with_jobs(
@@ -673,6 +681,7 @@ pub struct EditSchedule {
pub schedule: String,
pub timezone: String,
pub args: Option<serde_json::Value>,
pub summary: Option<String>,
pub on_failure: Option<String>,
pub on_failure_times: Option<i32>,
pub on_failure_exact: Option<bool>,
@@ -682,6 +691,7 @@ pub struct EditSchedule {
pub on_recovery_extra_args: Option<serde_json::Value>,
pub ws_error_handler_muted: Option<bool>,
pub retry: Option<serde_json::Value>,
pub no_flow_overlap: Option<bool>,
}
pub async fn clear_schedule<'c>(
+2
View File
@@ -37,6 +37,8 @@ pub struct Schedule {
pub on_recovery_extra_args: Option<serde_json::Value>,
pub ws_error_handler_muted: bool,
pub retry: Option<serde_json::Value>,
pub no_flow_overlap: bool,
pub summary: Option<String>,
}
impl Schedule {
+2
View File
@@ -1003,6 +1003,8 @@ pub async fn handle_maybe_scheduled_job<'c, R: rsmq_async::RsmqConnection + Clon
on_recovery_extra_args: schedule.on_recovery_extra_args,
ws_error_handler_muted: schedule.ws_error_handler_muted,
retry: schedule.retry,
summary: schedule.summary,
no_flow_overlap: schedule.no_flow_overlap,
},
)
.await;
@@ -1149,6 +1149,41 @@ async fn push_next_flow_job<R: rsmq_async::RsmqConnection + Send + Sync + Clone>
let arc_flow_job_args = Arc::new(flow_job_args.clone());
if i == 0 {
// if !flow_job.is_flow_step && flow_job.schedule_path.is_some() {
// let not_allow_overlap = sqlx::query_scalar!(
// "SELECT not_allow_overlap FROM schedule WHERE path = $1 AND workspace_id = $2",
// flow_job.schedule_path.as_ref().unwrap(),
// flow_job.workspace_id.as_str()
// )
// .fetch_one(db)
// .await?;
// if not_allow_overlap.fetch_one(db).await? {
// let count = sqlx::query_scalar!(
// "SELECT count(*) FROM queue WHERE schedule_path = $1 AND workspace_id = $2 AND id != $3 AND (flow_status->>'step')::int = 0",
// flow_job.schedule_path.as_ref().unwrap(),
// flow_job.workspace_id.as_str(),
// flow_job.id
// ).fetch_one(db).await?;
// if count > 1 {
// return update_flow_status_after_job_completion(
// db,
// client,
// flow_job.id,
// &Uuid::nil(),
// flow_job.workspace_id.as_str(),
// true,
// serde_json::from_str("\"not allowed to overlap\"").unwrap(),
// true,
// same_worker_tx,
// worker_dir,
// Some(true),
// rsmq,
// worker_name,
// )
// .await;
// }
// }
// }
if let Some(skip_expr) = &flow.skip_expr {
let skip = compute_bool_from_expr(
skip_expr.to_string(),
@@ -1,5 +1,5 @@
<script lang="ts">
import { Alert, Button, Tab, Tabs } from '$lib/components/common'
import { Alert, Badge, Button, Tab, Tabs } from '$lib/components/common'
import Drawer from '$lib/components/common/drawer/Drawer.svelte'
import DrawerContent from '$lib/components/common/drawer/DrawerContent.svelte'
import CronInput from '$lib/components/CronInput.svelte'
@@ -83,6 +83,7 @@
edit = false
itemKind = is_flow ? 'flow' : 'script'
initialScriptPath = initial_script_path ?? ''
summary = ''
path = initialScriptPath
initialPath = initialScriptPath
script_path = initialScriptPath
@@ -140,6 +141,7 @@
let path: string = ''
let enabled: boolean = false
let pathError = ''
let summary = ''
let validCRON = true
$: allowSchedule = isValid && validCRON && script_path != ''
@@ -232,6 +234,7 @@
enabled = s.enabled
schedule = s.schedule
timezone = s.timezone
summary = s.summary ?? ''
script_path = s.script_path ?? ''
is_flow = s.is_flow
wsErrorHandlerMuted = s.ws_error_handler_muted ?? false
@@ -295,7 +298,8 @@
on_recovery_times: recoveredTimes,
on_recovery_extra_args: recoveryHandlerPath ? recoveryHandlerExtraArgs : {},
ws_error_handler_muted: wsErrorHandlerMuted,
retry: retry
retry: retry,
summary: summary != '' ? summary : undefined
}
})
sendUserToast(`Schedule ${path} updated`)
@@ -320,7 +324,8 @@
on_recovery_times: recoveredTimes,
on_recovery_extra_args: recoveryHandlerPath ? recoveryHandlerExtraArgs : {},
ws_error_handler_muted: wsErrorHandlerMuted,
retry: retry
retry: retry,
summary: summary != '' ? summary : undefined
}
})
sendUserToast(`Schedule ${path} created`)
@@ -351,6 +356,9 @@
}
let drawer: Drawer
let pathC: Path
let dirtyPath = false
</script>
<Drawer size="900px" bind:this={drawer}>
@@ -402,9 +410,35 @@
</svelte:fragment>
<div class="flex flex-col gap-12">
{#if !edit}
<Section label="Metadata">
<div>
<div>
<h2 class="text-base font-semibold">Metadata</h2>
<div class="w-full py-2">
<!-- svelte-ignore a11y-autofocus -->
<input
autofocus
type="text"
placeholder="Schedule summary"
class="text-sm w-full font-semibold"
bind:value={summary}
on:keyup={() => {
if (!edit && summary?.length > 0 && !dirtyPath) {
pathC?.setName(
summary
.toLowerCase()
.replace(/[^a-z0-9_]/g, '_')
.replace(/-+/g, '_')
.replace(/^-|-$/g, '')
)
}
}}
/>
</div>
</div>
{#if !edit}
<Path
bind:dirty={dirtyPath}
bind:this={pathC}
checkInitialPathExistence
bind:error={pathError}
bind:path
@@ -412,8 +446,29 @@
namePlaceholder="schedule"
kind="schedule"
/>
</Section>
{/if}
{:else}
<div class="flex justify-start w-full">
<Badge
color="gray"
class="center-center !bg-surface-secondary !text-tertiary !h-[24px] rounded-r-none border"
>
Schedule path (not editable)
</Badge>
<input
type="text"
readonly
value={path}
size={path?.length || 50}
class="font-mono !text-xs max-w-[calc(100%-70px)] !w-auto !h-[24px] !py-0 !border-l-0 !rounded-l-none"
on:focus={({ currentTarget }) => {
currentTarget.select()
}}
/>
<!-- <span class="font-mono text-sm break-all">{path}</span> -->
</div>
{/if}
</div>
<Section label="Schedule">
<svelte:fragment slot="header">
<Tooltip>Schedules use CRON syntax. Seconds are mandatory.</Tooltip>
@@ -77,8 +77,8 @@
listItems = Array.isArray(resolvedConfig.items)
? resolvedConfig.items.map((item) => {
return {
label: item.label,
value: JSON.stringify(item.value)
label: item?.label ?? 'undefined',
value: item?.value != undefined ? JSON.stringify(item.value) : 'undefined'
}
})
: []
@@ -9,8 +9,6 @@
export let nodes: DecisionTreeNode[] = []
export let id: string
export let isConditionalDebugMode: boolean = false
const { componentControl } = getContext<AppViewerContext>('AppViewerContext')
const dispatch = createEventDispatcher()
@@ -18,7 +16,7 @@
</script>
<button
title={isConditionalDebugMode ? 'Debug conditions' : 'Debug tabs'}
title={'Debug tabs'}
class={classNames(
'text-2xs py-0.5 font-bold w-fit border cursor-pointer rounded-sm',
isManuallySelected
@@ -67,7 +67,7 @@
const actions: ToastAction[] = []
if (stateLoadedFromUrl) {
actions.push({
label: 'Discard URL stored autosave and reload',
label: 'Discard browser autosave and reload',
callback: reloadAction
})
@@ -110,7 +110,7 @@
{filter}
items={schedules}
bind:filteredItems
f={(x) => x.path + ' ' + x.script_path}
f={(x) => (x.summary ?? '') + ' ' + x.path + ' (' + x.script_path + ')'}
/>
<CenteredPage>
@@ -135,7 +135,7 @@
<div class="text-center text-sm text-tertiary mt-2"> No schedules </div>
{:else if filteredItems?.length}
<div class="border rounded-md divide-y">
{#each filteredItems as { path, error, edited_by, edited_at, schedule, timezone, enabled, script_path, is_flow, extra_perms, canWrite, args, marked, jobs }}
{#each filteredItems as { path, error, summary, edited_by, edited_at, schedule, timezone, enabled, script_path, is_flow, extra_perms, canWrite, args, marked, jobs }}
{@const href = `${is_flow ? '/flows/get' : '/scripts/get'}/${script_path}`}
{@const avg_s = jobs
? jobs.reduce((acc, x) => acc + x.duration_ms, 0) / jobs.length
@@ -159,7 +159,7 @@
{@html marked}
</span>
{:else}
{script_path}
{summary ?? script_path}
{/if}
</div>
<div class="text-secondary text-xs truncate text-left font-light">