UBER-174: Introduce createOn every there (#3222)

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev
2023-05-20 00:37:22 +07:00
committed by GitHub
parent 0f62a3175e
commit c0bb68be9e
50 changed files with 159 additions and 317 deletions
+6 -7
View File
@@ -257,10 +257,6 @@ export class TIssue extends TAttachedDoc implements Issue {
@Prop(Collection(tracker.class.TimeSpendReport), tracker.string.TimeSpendReports)
reports!: number
@Prop(TypeTimestamp(), tracker.string.CreatedDate)
@ReadOnly()
createOn!: Timestamp
declare childInfo: IssueChildInfo[]
}
@@ -1780,7 +1776,8 @@ export function createModel (builder: Builder): void {
groupBy: ['status'],
orderBy: [
['modifiedOn', SortingOrder.Descending],
['targetDate', SortingOrder.Descending]
['targetDate', SortingOrder.Descending],
['createOn', SortingOrder.Descending]
],
other: []
}
@@ -1852,7 +1849,8 @@ export function createModel (builder: Builder): void {
groupBy: ['lead'],
orderBy: [
['startDate', SortingOrder.Descending],
['modifiedOn', SortingOrder.Descending]
['modifiedOn', SortingOrder.Descending],
['createOn', SortingOrder.Descending]
],
other: []
}
@@ -1919,7 +1917,8 @@ export function createModel (builder: Builder): void {
groupBy: [],
orderBy: [
['startDate', SortingOrder.Descending],
['modifiedOn', SortingOrder.Descending]
['modifiedOn', SortingOrder.Descending],
['createOn', SortingOrder.Descending]
],
other: [],
groupDepth: 1
+8 -63
View File
@@ -15,34 +15,33 @@
import core, {
Class,
DOMAIN_STATUS,
DOMAIN_TX,
Doc,
DocumentUpdate,
DOMAIN_TX,
generateId,
Ref,
SortingOrder,
StatusCategory,
TxCollectionCUD,
TxCreateDoc,
TxOperations,
TxResult,
TxUpdateDoc,
DOMAIN_STATUS
generateId
} from '@hcengineering/core'
import { createOrUpdate, MigrateOperation, MigrationClient, MigrationUpgradeClient } from '@hcengineering/model'
import { MigrateOperation, MigrationClient, MigrationUpgradeClient, createOrUpdate } from '@hcengineering/model'
import { DOMAIN_SPACE } from '@hcengineering/model-core'
import tags from '@hcengineering/tags'
import {
calcRank,
genRanks,
Issue,
IssueStatus,
IssueTemplate,
IssueTemplateChild,
Project,
Milestone,
MilestoneStatus,
TimeReportDayType
Project,
TimeReportDayType,
calcRank,
genRanks
} from '@hcengineering/tracker'
import { DOMAIN_TRACKER } from '.'
import tracker from './plugin'
@@ -851,59 +850,6 @@ async function renameProject (client: MigrationClient): Promise<void> {
)
}
async function setCreate (client: MigrationClient): Promise<void> {
while (true) {
const docs = await client.find<Issue>(
DOMAIN_TRACKER,
{
_class: tracker.class.Issue,
createOn: { $exists: false }
},
{ limit: 500 }
)
if (docs.length === 0) {
break
}
const creates = await client.find<TxCollectionCUD<Issue, Issue>>(DOMAIN_TX, {
'tx.objectId': { $in: docs.map((it) => it._id) },
'tx._class': core.class.TxCreateDoc
})
for (const doc of docs) {
const tx = creates.find((it) => it.tx.objectId === doc._id)
if (tx !== undefined) {
await client.update(
DOMAIN_TRACKER,
{
_id: doc._id
},
{
createOn: tx.modifiedOn
}
)
await client.update(
DOMAIN_TX,
{
_id: tx._id
},
{
'tx.attributes.createOn': tx.modifiedOn
}
)
} else {
await client.update(
DOMAIN_TRACKER,
{
_id: doc._id
},
{
createOn: doc.modifiedOn
}
)
}
}
}
}
async function fixMilestoneEmptyStatuses (client: MigrationClient): Promise<void> {
await client.update<Milestone>(
DOMAIN_TRACKER,
@@ -928,7 +874,6 @@ export const trackerOperation: MigrateOperation = {
await fillRank(client)
await renameSprintToMilestone(client)
await renameProject(client)
await setCreate(client)
// Move all status objects into status domain
await client.move(