Fix done state filter (#3760)

Signed-off-by: Vyacheslav Tumanov <me@slavatumanov.me>
This commit is contained in:
Vyacheslav Tumanov 2023-09-29 11:22:54 +05:00 committed by GitHub
parent c16970f357
commit 0154d7567e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -127,12 +127,19 @@
const res: Map<Ref<Status>, string> = new Map() const res: Map<Ref<Status>, string> = new Map()
for (const state of statuses) { for (const state of statuses) {
if (res.has(state._id)) continue if (res.has(state._id)) continue
space = await client.findOne(task.class.SpaceWithStates, { states: state._id }) const query = hierarchy.isDerived(state._class, task.class.DoneState)
? { doneStates: state._id }
: { states: state._id }
space = (await client.findOne(task.class.SpaceWithStates, query)) as SpaceWithStates | undefined
if (space === undefined) continue if (space === undefined) continue
for (let index = 0; index < space.states.length; index++) { const spaceStateArray = hierarchy.isDerived(state._class, task.class.DoneState)
const st = space.states[index] ? space.doneStates
const prev = index > 0 ? res.get(space.states[index - 1]) : undefined : space.states
const next = index < space.states.length - 1 ? res.get(space.states[index + 1]) : undefined if (spaceStateArray === undefined) continue
for (let index = 0; index < spaceStateArray.length; index++) {
const st = spaceStateArray[index]
const prev = index > 0 ? res.get(spaceStateArray[index - 1]) : undefined
const next = index < spaceStateArray.length - 1 ? res.get(spaceStateArray[index + 1]) : undefined
res.set(st, calcRank(prev ? { rank: prev } : undefined, next ? { rank: next } : undefined)) res.set(st, calcRank(prev ? { rank: prev } : undefined, next ? { rank: next } : undefined))
} }
} }