mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-13 19:58:09 +00:00
Fix user model updates (#924)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
parent
5599a8c257
commit
e7c0f2406a
@ -134,7 +134,14 @@ export async function createClient (
|
||||
}
|
||||
|
||||
const conn = await connect(txHander)
|
||||
const txes = await conn.findAll(core.class.Tx, { objectSpace: core.space.Model }, { sort: { _id: SortingOrder.Ascending } })
|
||||
const atxes = await conn.findAll(core.class.Tx, { objectSpace: core.space.Model }, { sort: { _id: SortingOrder.Ascending } })
|
||||
|
||||
const systemTr: Tx[] = []
|
||||
const userTx: Tx[] = []
|
||||
|
||||
atxes.forEach(tx => ((tx.modifiedBy === core.account.System) ? systemTr : userTx).push(tx))
|
||||
|
||||
const txes = systemTr.concat(userTx)
|
||||
|
||||
const txMap = new Map<Ref<Tx>, Ref<Tx>>()
|
||||
for (const tx of txes) txMap.set(tx._id, tx._id)
|
||||
|
@ -525,7 +525,14 @@ class MongoTxAdapter extends MongoAdapterBase implements TxAdapter {
|
||||
}
|
||||
|
||||
async getModel (): Promise<Tx[]> {
|
||||
return await this.db.collection(DOMAIN_TX).find<Tx>({ objectSpace: core.space.Model }).sort({ _id: 1 }).toArray()
|
||||
const model = await this.db.collection(DOMAIN_TX).find<Tx>({ objectSpace: core.space.Model }).sort({ _id: 1 }).toArray()
|
||||
// We need to put all core.account.System transactions first
|
||||
const systemTr: Tx[] = []
|
||||
const userTx: Tx[] = []
|
||||
|
||||
model.forEach(tx => ((tx.modifiedBy === core.account.System) ? systemTr : userTx).push(tx))
|
||||
|
||||
return systemTr.concat(userTx)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user