Add component migration (#2764)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov 2023-03-17 22:01:35 +06:00 committed by GitHub
parent 34b8a6cdd2
commit 892e7b1dbc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 5 deletions

View File

@ -53,9 +53,13 @@ export async function generateIssues (
const client = new TxOperations(connection, account._id)
const ctx = new MeasureMetricsContext('recruit', {})
const statuses = (await client.findAll(tracker.class.IssueStatus, { space }, { projection: { _id: 1 } })).map(
(p) => p._id
)
for (let index = 0; index < options.count; index++) {
console.log(`Generating issue ${index + 1}...`)
await genIssue(client)
await genIssue(client, statuses)
}
await connection.close()
@ -64,7 +68,7 @@ export async function generateIssues (
console.info(metricsToString(ctx.metrics, 'Client'))
}
async function genIssue (client: TxOperations): Promise<void> {
async function genIssue (client: TxOperations, statuses: Ref<IssueStatus>[]): Promise<void> {
const lastOne = await client.findOne<Issue>(tracker.class.Issue, {}, { sort: { rank: SortingOrder.Descending } })
const incResult = await client.updateDoc(
tracker.class.Project,
@ -76,14 +80,14 @@ async function genIssue (client: TxOperations): Promise<void> {
true
)
const value: AttachedData<Issue> = {
title: faker.name.title(),
title: faker.commerce.productName(),
description: faker.lorem.paragraphs(),
assignee: object.assignee,
component: object.component,
sprint: object.sprint,
number: (incResult as any).object.sequence,
status: object.status,
priority: object.priority,
status: faker.random.arrayElement(statuses),
priority: faker.random.arrayElement(Object.values(IssuePriority)) as IssuePriority,
rank: calcRank(lastOne, undefined),
comments: 0,
subIssues: 0,

View File

@ -429,6 +429,29 @@ async function renameProject (client: MigrationClient): Promise<void> {
$rename: { project: 'component' }
}
)
await client.update(
DOMAIN_TRACKER,
{
_id: tracker.class.Project
},
{
_class: tracker.class.Component
}
)
const components = await client.find(DOMAIN_TRACKER, { _class: tracker.class.Component })
for (const component of components) {
await client.update(
DOMAIN_TX,
{
objectId: component._id,
objectClass: tracker.class.Project
},
{
objectClass: tracker.class.Component
}
)
}
await client.update(
DOMAIN_TX,
{