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;
|
std::unordered_map<int, Task *> tasks;
|
||||||
for (auto iterator = ret.begin(); iterator != ret.end();) {
|
for (auto iterator = ret.begin(); iterator != ret.end();) {
|
||||||
if (iterator->parentId >= 0) {
|
if (iterator->parentId >= 0) {
|
||||||
auto parentTask = tasks.at(iterator->parentId);
|
if (tasks.count(iterator->parentId) > 0) {
|
||||||
parentTask->children.push_back(*iterator);
|
auto parentTask = tasks.at(iterator->parentId);
|
||||||
tasks.insert({iterator->id, &parentTask->children.back()});
|
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);
|
iterator = ret.erase(iterator);
|
||||||
} else {
|
} else {
|
||||||
tasks.insert({iterator->id, &(*iterator)});
|
tasks.insert({iterator->id, &(*iterator)});
|
||||||
|
Loading…
Reference in New Issue
Block a user