From 5175381f0607cc7cc092fc06e333cb0a0e65a4cb Mon Sep 17 00:00:00 2001 From: Andrey Sobolev Date: Fri, 13 Dec 2024 21:09:52 +0700 Subject: [PATCH] UBERF-8851: Fix isDone is wrong (#7456) --- models/task/src/migration.ts | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/models/task/src/migration.ts b/models/task/src/migration.ts index 03c06f7c69..259d456fc0 100644 --- a/models/task/src/migration.ts +++ b/models/task/src/migration.ts @@ -572,6 +572,37 @@ export const taskOperation: MigrateOperation = { { state: 'migrateRanks', func: migrateRanks + }, + { + state: 'migrate_wrong_isdone', + func: async (client: MigrationClient) => { + const statuses = client.model.findAllSync(core.class.Status, { + category: { $in: [task.statusCategory.Won, task.statusCategory.Lost] } + }) + + await client.update( + DOMAIN_TASK, + { + _class: { $in: client.hierarchy.getDescendants(task.class.Task) }, + status: { $in: statuses.map((it) => it._id) }, + isDone: false + }, + { + isDone: true + } + ) + await client.update( + DOMAIN_TASK, + { + _class: { $in: client.hierarchy.getDescendants(task.class.Task) }, + status: { $nin: statuses.map((it) => it._id) }, + isDone: true + }, + { + isDone: false + } + ) + } } ]) },