Add task condition.
This commit is contained in:
parent
379f54a797
commit
64c21878f5
@ -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) {
|
||||
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)});
|
||||
|
Loading…
Reference in New Issue
Block a user