Add task condition.

This commit is contained in:
amass 2024-02-17 23:21:19 +08:00
parent 379f54a797
commit 64c21878f5

View File

@ -47,9 +47,13 @@ Tasks Database::tasks() {
std::unordered_map<int, Task *> tasks;
for (auto iterator = ret.begin(); iterator != ret.end();) {
if (iterator->parentId >= 0) {
auto parentTask = tasks.at(iterator->parentId);
parentTask->children.push_back(*iterator);
tasks.insert({iterator->id, &parentTask->children.back()});
if (tasks.count(iterator->parentId) > 0) {
auto parentTask = tasks.at(iterator->parentId);
parentTask->children.push_back(*iterator);
tasks.insert({iterator->id, &parentTask->children.back()});
} else {
LOG(warning) << "task`s parent id " << iterator->parentId << " not existed.";
}
iterator = ret.erase(iterator);
} else {
tasks.insert({iterator->id, &(*iterator)});