mirror of
https://github.com/hcengineering/platform.git
synced 2025-06-11 21:11:57 +00:00
Fix card migration loop (#9176)
Signed-off-by: Artem Savchenko <armisav@gmail.com>
This commit is contained in:
parent
852137c213
commit
c8604703e8
@ -103,15 +103,21 @@ async function fillParentInfo (client: Client): Promise<void> {
|
||||
async function getCardParentWithParentInfo (
|
||||
txOp: TxOperations,
|
||||
_id: Ref<Card>,
|
||||
cache: Map<Ref<Card>, Card>
|
||||
cache: Map<Ref<Card>, Card>,
|
||||
visited: Set<Ref<Card>> = new Set<Ref<Card>>()
|
||||
): Promise<Card | undefined> {
|
||||
if (visited.has(_id)) {
|
||||
return undefined
|
||||
}
|
||||
const doc = cache.get(_id) ?? (await txOp.findOne(card.class.Card, { _id }))
|
||||
if (doc === undefined) return
|
||||
if (doc.parentInfo === undefined) {
|
||||
if (doc.parent == null) {
|
||||
doc.parentInfo = []
|
||||
} else {
|
||||
visited.add(_id) // Add current card to visited set before recursing
|
||||
const parent = await getCardParentWithParentInfo(txOp, doc.parent, cache)
|
||||
visited.delete(_id)
|
||||
if (parent !== undefined) {
|
||||
doc.parentInfo = [
|
||||
...(parent.parentInfo ?? []),
|
||||
@ -122,6 +128,7 @@ async function getCardParentWithParentInfo (
|
||||
}
|
||||
]
|
||||
} else {
|
||||
doc.parent = null
|
||||
doc.parentInfo = []
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user