implement get_task_status
This commit is contained in:
parent
e5f54e4a29
commit
11714d09db
1 changed files with 22 additions and 3 deletions
|
|
@ -211,9 +211,28 @@ JobStatusType Connection::get_job_status(std::string job) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JobStatusType Connection::get_task_status(db::uuid_t) {
|
JobStatusType Connection::get_task_status(db::uuid_t task) {
|
||||||
std::cout << "JOB STATUS called, implement me pls" << std::endl;
|
|
||||||
return JobStatusType::IN_PROGRESS;
|
auto get_task_status_lambda = [](pqxx::work *txn, db::uuid_t *task, db::JobStatusType *status){
|
||||||
|
auto res = txn->exec_params("SELECT part_status FROM artifacts WHERE id = $1 LIMIT 1;", *task);
|
||||||
|
|
||||||
|
if (res.size() < 1) {
|
||||||
|
*status = db::JobStatusType::UNKNOWN;
|
||||||
|
} else {
|
||||||
|
*status = res[0]["part_status"].as<db::JobStatusType>();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
std::function<void(pqxx::work*, db::uuid_t*, db::JobStatusType*)> get_task_status_func = get_task_status_lambda;
|
||||||
|
|
||||||
|
db::JobStatusType status;
|
||||||
|
|
||||||
|
if (!this->send_request(&get_task_status_func, &task, &status)) {
|
||||||
|
std::cerr << "Error: Status for task " << db::to_string(task) << " could not be fetched, returning unknown." << std::endl;
|
||||||
|
return db::JobStatusType::UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue