From 800f846228dbf39fd76856429cd3bb938252ba72 Mon Sep 17 00:00:00 2001 From: Denis Bykhov Date: Fri, 5 Jan 2024 15:12:38 +0600 Subject: [PATCH] UBERF-4840 (#4308) Signed-off-by: Denis Bykhov --- models/tracker/src/migration.ts | 66 ++++++++++++++++----------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/models/tracker/src/migration.ts b/models/tracker/src/migration.ts index 04ada9323c..2f809244f7 100644 --- a/models/tracker/src/migration.ts +++ b/models/tracker/src/migration.ts @@ -15,17 +15,16 @@ import core, { DOMAIN_STATUS, - SortingOrder, + DOMAIN_TX, TxOperations, + TxProcessor, generateId, + toIdMap, type Data, type Ref, type Status, - toIdMap, - DOMAIN_TX, - type TxCreateDoc, - TxProcessor, - type Tx + type Tx, + type TxCreateDoc } from '@hcengineering/core' import { createOrUpdate, @@ -39,14 +38,14 @@ import { DOMAIN_TASK, createProjectType, fixTaskTypes } from '@hcengineering/mod import tags from '@hcengineering/tags' import task, { type ProjectType, type TaskType } from '@hcengineering/task' import { - type IssueStatus, TimeReportDayType, baseIssueTaskStatuses, classicIssueTaskStatuses, - createStatesData + createStatesData, + type IssueStatus } from '@hcengineering/tracker' -import tracker from './plugin' import { PaletteColorIndexes } from '@hcengineering/ui/src/colors' +import tracker from './plugin' async function createDefaultProject (tx: TxOperations): Promise { const current = await tx.findOne(tracker.class.Project, { @@ -119,30 +118,31 @@ async function createDefaultProject (tx: TxOperations): Promise { // Create new if not deleted by customers. if (current === undefined && currentDeleted === undefined) { - const state = await tx.findOne( - tracker.class.IssueStatus, - { space: tracker.ids.DefaultProjectType }, - { sort: { rank: SortingOrder.Ascending } } - ) - if (state !== undefined) { - await tx.createDoc( - tracker.class.Project, - core.space.Space, - { - name: 'Default', - description: 'Default project', - private: false, - members: [], - archived: false, - identifier: 'TSK', - sequence: 0, - defaultIssueStatus: state._id, - defaultTimeReportDay: TimeReportDayType.PreviousWorkDay, - defaultAssignee: undefined, - type: tracker.ids.ClassingProjectType - }, - tracker.project.DefaultProject - ) + const taskType = await tx.findOne(task.class.TaskType, { + _id: tracker.taskTypes.Issue + }) + if (taskType !== undefined) { + const state = await tx.findOne(core.class.Status, { _id: taskType.statuses[0] }) + if (state !== undefined) { + await tx.createDoc( + tracker.class.Project, + core.space.Space, + { + name: 'Default', + description: 'Default project', + private: false, + members: [], + archived: false, + identifier: 'TSK', + sequence: 0, + defaultIssueStatus: state._id, + defaultTimeReportDay: TimeReportDayType.PreviousWorkDay, + defaultAssignee: undefined, + type: tracker.ids.ClassingProjectType + }, + tracker.project.DefaultProject + ) + } } } }