From 5f013f9efae96c26ead5ef97fbc53ec097dd5b65 Mon Sep 17 00:00:00 2001 From: Fabian Posch Date: Tue, 16 Jan 2024 18:34:18 -0500 Subject: [PATCH] implement upload --- src/actsim_agent/uploader.cpp | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/src/actsim_agent/uploader.cpp b/src/actsim_agent/uploader.cpp index 7366ddb..b5f384f 100644 --- a/src/actsim_agent/uploader.cpp +++ b/src/actsim_agent/uploader.cpp @@ -23,6 +23,9 @@ ************************************************************************** */ +#include +#include +#include #include "util.h" #include "uploader.hpp" @@ -99,10 +102,31 @@ void Uploader::thread_run() { } } -bool Uploader::upload_task([[maybe_unused]]std::unique_ptr task) { +bool Uploader::upload_task(std::unique_ptr task) { // make sure any task that is uploaded isn't halted in the database + auto task_upload_lambda = []( + pqxx::work *txn, + const db::uuid_t *target, + std::vector *sim_log, + std::vector *sim_error + ) { + txn->exec_params0( + "UPDATE sim_outputs SET sim_log = $1, error_log = $2 WHERE id = $3 AND part_status != 'halted';", + *sim_log, + *sim_error, + *target + ); + }; - std::cout << "[UPLOADER] Task uploaded!" << std::endl; - return true; + std::function*, + std::vector* + )> task_upload_func = task_upload_lambda; + + DEBUG_PRINT("Updating task " + db::to_string(task->id)); + + return this->conn->send_request(&task_upload_func, &(task->id), &(task->get_content().first), &(task->get_content().second)); }