Skip to content
This repository has been archived by the owner on Aug 13, 2024. It is now read-only.

Commit

Permalink
wip(backend): do not execute validation scripts when calling ../execu…
Browse files Browse the repository at this point in the history
…te endpoint + fixing status update
  • Loading branch information
evoxmusic committed Jan 7, 2024
1 parent 7c8cab1 commit 0523fea
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
10 changes: 0 additions & 10 deletions backend/src/catalog/controllers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,6 @@ pub async fn exec_catalog_service_post_validate_scripts(
Err(err) => return err
};

// execute validate scripts
for cmd in service.validate.as_ref().unwrap_or(&vec![]) {
let _ = match execute_command(cmd, req.payload.to_string().as_str()).await {
Ok(_) => (),
Err(err) => return (StatusCode::BAD_REQUEST, Json(JobResponse {
message: Some(err),
}))
};
}

let ces = match insert_catalog_run(
&pg_pool,
&catalog_slug,
Expand Down
15 changes: 13 additions & 2 deletions backend/src/catalog/services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ pub async fn background_worker(mut rx: Receiver<BackgroundWorkerTask>, pg_pool:

let mut tasks = Vec::<TaskPayload>::new();

let mut last_task_value = serde_json::Value::Array(vec![]);

for cmd in task.catalog_service_yaml_config.post_validate.as_ref().unwrap_or(&vec![]) {
let job_output_result = match execute_command(cmd, task.req.payload.to_string().as_str()).await {
Ok(job_output_result) => job_output_result,
Expand Down Expand Up @@ -89,12 +91,21 @@ pub async fn background_worker(mut rx: Receiver<BackgroundWorkerTask>, pg_pool:

let _ = tasks.push(task_payload);

last_task_value = serde_json::to_value(tasks.clone()).unwrap();

let _ = update_catalog_run(
&pg_pool,
task.catalog_execution_status_id.as_str(),
Status::Success,
&serde_json::to_value(tasks.clone()).unwrap(),
Status::Running,
&last_task_value,
).await;
}

let _ = update_catalog_run(
&pg_pool,
task.catalog_execution_status_id.as_str(),
Status::Success,
&last_task_value,
).await;
}
}

0 comments on commit 0523fea

Please sign in to comment.