implement command parsing, top process indication, db version bump

This commit is contained in:
Fabian Posch 2024-01-16 16:57:18 -05:00
parent 012b56f7d6
commit caf2afc603
2 changed files with 20 additions and 2 deletions

View file

@ -28,7 +28,7 @@
#include <cluster/db_types.hpp>
#define DATABASE_VERSION 2
#define DATABASE_VERSION 3
#define DOWNLOAD_BUFFER 5

View file

@ -113,6 +113,7 @@ bool Downloader::fetch_tasks(size_t n) {
pqxx::row res = txn->exec1(
"SELECT "
" ap.design_file AS design, "
" ap.top_proc, "
" ap.outputs AS target_artifact, "
" ap.id AS source_pass, "
" sc.id AS source_config, "
@ -135,7 +136,7 @@ bool Downloader::fetch_tasks(size_t n) {
);
// seems like there is nothing to do right now
if (res.empty()) {
if (res.size() > 0) {
*task_avail = false;
return;
}
@ -147,6 +148,23 @@ bool Downloader::fetch_tasks(size_t n) {
*design = res["design"].as<db::uuid_t>();
*source_config = res["source_config"].as<db::uuid_t>();
std::vector<std::string> commands;
auto arr = res["sim_commands"].as_array();
std::pair<pqxx::array_parser::juncture, std::string> elem;
do {
elem = arr.get_next();
if (elem.first == pqxx::array_parser::juncture::string_value) {
commands.push_back(elem.second);
}
} while (elem.first != pqxx::array_parser::juncture::done);
*testcase = {
commands,
res["top_proc"].as<std::string>(),
false,
0
};
if (res["id"].is_null()) {
// create a new sim output row in the database
pqxx::row new_row = txn->exec_params1(