mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-22 16:27:22 +00:00
fix: sort model (#7053)
Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com>
This commit is contained in:
parent
cf6ff9293d
commit
be8903ab96
@ -441,6 +441,8 @@ async function buildModel (
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
userTx.sort(compareTxes)
|
||||||
|
|
||||||
let txes = systemTx.concat(userTx)
|
let txes = systemTx.concat(userTx)
|
||||||
if (modelFilter !== undefined) {
|
if (modelFilter !== undefined) {
|
||||||
txes = await modelFilter(txes)
|
txes = await modelFilter(txes)
|
||||||
@ -473,3 +475,8 @@ function getLastTxTime (txes: Tx[]): number {
|
|||||||
}
|
}
|
||||||
return lastTxTime
|
return lastTxTime
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function compareTxes (a: Tx, b: Tx): number {
|
||||||
|
const result = a._id.localeCompare(b._id)
|
||||||
|
return result !== 0 ? result : a.modifiedOn - b.modifiedOn
|
||||||
|
}
|
||||||
|
@ -1613,7 +1613,7 @@ class MongoTxAdapter extends MongoAdapterBase implements TxAdapter {
|
|||||||
@withContext('get-model')
|
@withContext('get-model')
|
||||||
async getModel (ctx: MeasureContext): Promise<Tx[]> {
|
async getModel (ctx: MeasureContext): Promise<Tx[]> {
|
||||||
const txCollection = this.db.collection<Tx>(DOMAIN_TX)
|
const txCollection = this.db.collection<Tx>(DOMAIN_TX)
|
||||||
const cursor = txCollection.find({ objectSpace: core.space.Model })
|
const cursor = txCollection.find({ objectSpace: core.space.Model }, { sort: { _id: 1, modifiedOn: 1 } })
|
||||||
const model = await toArray<Tx>(cursor)
|
const model = await toArray<Tx>(cursor)
|
||||||
// We need to put all core.account.System transactions first
|
// We need to put all core.account.System transactions first
|
||||||
const systemTx: Tx[] = []
|
const systemTx: Tx[] = []
|
||||||
|
Loading…
Reference in New Issue
Block a user