-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update paths object to return array of path objects #11
Conversation
std::string path_query = "SELECT path, recursive FROM paths WHERE lot_name = ?;"; | ||
//std::string recursive_query = "SELECT recursive FROM paths WHERE path = ? AND lot_name = ?;"; | ||
std::map<std::string, std::vector<int>> path_query_str_map{{lot_name, {1}}}; | ||
auto rp = lotman::Checks::SQL_get_matches_multi_col(path_query, 2, path_query_str_map); | ||
if (!rp.second.empty()) { // There was an error | ||
std::string int_err = rp.second; | ||
std::string ext_err = "Failure on call to SQL_get_matches_multi_col: "; | ||
return std::make_pair(path_obj, ext_err + int_err); | ||
return std::make_pair(path_arr, ext_err + int_err); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[lint] reported by reviewdog 🐶
} | |
} |
std::string path_query = "SELECT path, recursive FROM paths WHERE lot_name = ?;"; | ||
//std::string recursive_query = "SELECT recursive FROM paths WHERE path = ? AND lot_name = ?;"; | ||
std::map<std::string, std::vector<int>> path_query_str_map{{lot_name, {1}}}; | ||
auto rp = lotman::Checks::SQL_get_matches_multi_col(path_query, 2, path_query_str_map); | ||
if (!rp.second.empty()) { // There was an error | ||
std::string int_err = rp.second; | ||
std::string ext_err = "Failure on call to SQL_get_matches_multi_col: "; | ||
return std::make_pair(path_obj, ext_err + int_err); | ||
return std::make_pair(path_arr, ext_err + int_err); | ||
} | ||
|
||
for (const auto &path_rec : rp.first) { // the path is at index 0, and the recursion of the path is at index 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[lint] reported by reviewdog 🐶
for (const auto &path_rec : rp.first) { // the path is at index 0, and the recursion of the path is at index 1 | |
for (const auto &path_rec : rp.first) { |
path_obj_internal["lot_name"] = this->lot_name; | ||
path_obj_internal["recursive"] = static_cast<bool>(std::stoi(path_rec[1])); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[lint] reported by reviewdog 🐶
path_obj_internal["lot_name"] = this->lot_name; | |
path_obj_internal["recursive"] = static_cast<bool>(std::stoi(path_rec[1])); | |
path_obj_internal["lot_name"] = child.lot_name; | |
path_obj_internal["recursive"] = | |
static_cast<bool>(std::stoi(path_rec[1])); |
} | ||
|
||
for (const auto &path_rec : rp.first) { // the path is at index 0, and the recursion of the path is at index 1 | ||
json path_obj_internal; | ||
path_obj_internal["lot_name"] = this->lot_name; | ||
path_obj_internal["recursive"] = static_cast<bool>(std::stoi(path_rec[1])); | ||
path_obj[path_rec[0]] = path_obj_internal; | ||
path_obj_internal["path"] = path_rec[0]; | ||
path_arr.push_back(path_obj_internal); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[lint] reported by reviewdog 🐶
} | |
} | |
} |
} | ||
|
||
for (const auto &path_rec : rp.first) { // the path is at index 0, and the recursion of the path is at index 1 | ||
json path_obj_internal; | ||
path_obj_internal["lot_name"] = this->lot_name; | ||
path_obj_internal["recursive"] = static_cast<bool>(std::stoi(path_rec[1])); | ||
path_obj[path_rec[0]] = path_obj_internal; | ||
path_obj_internal["path"] = path_rec[0]; | ||
path_arr.push_back(path_obj_internal); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[lint] reported by reviewdog 🐶
} | |
else { | ||
ASSERT_TRUE(false) << "Unexpected path object: " << output; | ||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[lint] reported by reviewdog 🐶
} | |
} | |
json expected_output = R"({"children":["lot4","lot5"],"lot_name":"lot3","management_policy_attrs":{"creation_time":{"lot_name":"lot3","value":123.0},"dedicated_GB":{"lot_name":"sep_node","value":3.0},"deletion_time":{"lot_name":"lot3","value":333.0},"expiration_time":{"lot_name":"lot3","value":222.0},"max_num_objects":{"lot_name":"sep_node","value":10.0},"opportunistic_GB":{"lot_name":"lot2","value":1.5}},"owners":["not owner1","owner1"],"parents":["lot1","lot2","sep_node"],"paths":{"/1/2/3/4":{"lot_name":"lot4","recursive":true},"/345":{"lot_name":"lot4","recursive":true},"/456":{"lot_name":"lot5","recursive":false},"/567":{"lot_name":"lot5","recursive":true},"/another/path":{"lot_name":"lot3","recursive":true},"/foo/barr":{"lot_name":"lot3","recursive":true},"/updated/path":{"lot_name":"lot3","recursive":false}},"usage":{"GB_being_written":{"children_contrib":3.4,"self_contrib":0.0},"dedicated_GB":{"children_contrib":8.64,"self_contrib":0.0,"total":8.64},"num_objects":{"children_contrib":10.0,"self_contrib":0.0},"objects_being_written":{"children_contrib":7.0,"self_contrib":0.0},"opportunistic_GB":{"children_contrib":0.0,"self_contrib":0.0,"total":0.0},"total_GB":{"children_contrib":8.64,"self_contrib":0.0}}})"_json; | ||
ASSERT_TRUE(output_JSON == expected_output); | ||
json expected_output = R"({"children":["lot4","lot5"],"lot_name":"lot3","management_policy_attrs":{"creation_time":{"lot_name":"lot3","value":123.0},"dedicated_GB":{"lot_name":"sep_node","value":3.0},"deletion_time":{"lot_name":"lot3","value":333.0},"expiration_time":{"lot_name":"lot3","value":222.0},"max_num_objects":{"lot_name":"sep_node","value":10.0},"opportunistic_GB":{"lot_name":"lot2","value":1.5}},"owners":["not owner1","owner1"],"parents":["lot1","lot2","sep_node"],"paths":[{"lot_name":"lot3","path":"/another/path","recursive":true},{"lot_name":"lot3","path":"/updated/path","recursive":false},{"lot_name":"lot3","path":"/foo/barr","recursive":true},{"lot_name":"lot4","path":"/1/2/3/4","recursive":true},{"lot_name":"lot4","path":"/345","recursive":true},{"lot_name":"lot5","path":"/456","recursive":false},{"lot_name":"lot5","path":"/567","recursive":true}],"usage":{"GB_being_written":{"children_contrib":3.4,"self_contrib":0.0},"dedicated_GB":{"children_contrib":8.64,"self_contrib":0.0,"total":8.64},"num_objects":{"children_contrib":10.0,"self_contrib":0.0},"objects_being_written":{"children_contrib":7.0,"self_contrib":0.0},"opportunistic_GB":{"children_contrib":0.0,"self_contrib":0.0,"total":0.0},"total_GB":{"children_contrib":8.64,"self_contrib":0.0}}})"_json; | ||
ASSERT_TRUE(output_JSON == expected_output) << output_JSON; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[lint] reported by reviewdog 🐶
} | |
ASSERT_FALSE(check); | |
lotman_free_string_list(output3); | |
// Check for lots past dedicated storage limit | |
char **output4; | |
rv = lotman_get_lots_past_ded(true, true, &output4, &err_msg); | |
ASSERT_TRUE(rv == 0) << err_msg; | |
check = false; | |
for (int iter = 0; output4[iter]; iter++) { | |
if (strcmp(output4[iter], "default") == 0) { | |
check = true; | |
} | |
} | |
ASSERT_FALSE(check); | |
lotman_free_string_list(output4); | |
// Check for lots past object storage limit | |
char **output5; | |
rv = lotman_get_lots_past_obj(true, true, &output5, &err_msg); | |
ASSERT_TRUE(rv == 0) << err_msg; | |
check = false; | |
for (int iter = 0; output5[iter]; iter++) { | |
if (strcmp(output5[iter], "default") == 0) { | |
check = true; | |
} | |
} | |
ASSERT_FALSE(check); | |
lotman_free_string_list(output5); | |
} | |
Closes #8