mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-27 19:00:02 +00:00
Add component migration (#2764)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
34b8a6cdd2
commit
892e7b1dbc
@ -53,9 +53,13 @@ export async function generateIssues (
|
|||||||
const client = new TxOperations(connection, account._id)
|
const client = new TxOperations(connection, account._id)
|
||||||
const ctx = new MeasureMetricsContext('recruit', {})
|
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++) {
|
for (let index = 0; index < options.count; index++) {
|
||||||
console.log(`Generating issue ${index + 1}...`)
|
console.log(`Generating issue ${index + 1}...`)
|
||||||
await genIssue(client)
|
await genIssue(client, statuses)
|
||||||
}
|
}
|
||||||
|
|
||||||
await connection.close()
|
await connection.close()
|
||||||
@ -64,7 +68,7 @@ export async function generateIssues (
|
|||||||
console.info(metricsToString(ctx.metrics, 'Client'))
|
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 lastOne = await client.findOne<Issue>(tracker.class.Issue, {}, { sort: { rank: SortingOrder.Descending } })
|
||||||
const incResult = await client.updateDoc(
|
const incResult = await client.updateDoc(
|
||||||
tracker.class.Project,
|
tracker.class.Project,
|
||||||
@ -76,14 +80,14 @@ async function genIssue (client: TxOperations): Promise<void> {
|
|||||||
true
|
true
|
||||||
)
|
)
|
||||||
const value: AttachedData<Issue> = {
|
const value: AttachedData<Issue> = {
|
||||||
title: faker.name.title(),
|
title: faker.commerce.productName(),
|
||||||
description: faker.lorem.paragraphs(),
|
description: faker.lorem.paragraphs(),
|
||||||
assignee: object.assignee,
|
assignee: object.assignee,
|
||||||
component: object.component,
|
component: object.component,
|
||||||
sprint: object.sprint,
|
sprint: object.sprint,
|
||||||
number: (incResult as any).object.sequence,
|
number: (incResult as any).object.sequence,
|
||||||
status: object.status,
|
status: faker.random.arrayElement(statuses),
|
||||||
priority: object.priority,
|
priority: faker.random.arrayElement(Object.values(IssuePriority)) as IssuePriority,
|
||||||
rank: calcRank(lastOne, undefined),
|
rank: calcRank(lastOne, undefined),
|
||||||
comments: 0,
|
comments: 0,
|
||||||
subIssues: 0,
|
subIssues: 0,
|
||||||
|
@ -429,6 +429,29 @@ async function renameProject (client: MigrationClient): Promise<void> {
|
|||||||
$rename: { project: 'component' }
|
$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(
|
await client.update(
|
||||||
DOMAIN_TX,
|
DOMAIN_TX,
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user