mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-12 20:57:45 +02:00
UBERF-9114: Optimize memory usage (#7643)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
@@ -743,6 +743,8 @@ abstract class PostgresAdapterBase implements DbAdapter {
|
||||
if (column === 'createdOn' || column === 'modifiedOn') {
|
||||
const val = Number.parseInt(row[column])
|
||||
;(doc as any)[column] = Number.isNaN(val) ? null : val
|
||||
} else if (column === '%hash%') {
|
||||
// Ignore
|
||||
} else {
|
||||
;(doc as any)[column] = row[column] === 'NULL' ? null : row[column]
|
||||
}
|
||||
@@ -1285,6 +1287,22 @@ abstract class PostgresAdapterBase implements DbAdapter {
|
||||
return []
|
||||
}
|
||||
|
||||
stripHash<T extends Doc>(docs: T | T[]): T | T[] {
|
||||
if (Array.isArray(docs)) {
|
||||
docs.forEach((it) => {
|
||||
if ('%hash%' in it) {
|
||||
delete it['%hash%']
|
||||
}
|
||||
return it
|
||||
})
|
||||
} else if (typeof docs === 'object' && docs != null) {
|
||||
if ('%hash%' in docs) {
|
||||
delete docs['%hash%']
|
||||
}
|
||||
}
|
||||
return docs
|
||||
}
|
||||
|
||||
strimSize (str?: string): string {
|
||||
if (str == null) {
|
||||
return ''
|
||||
@@ -1841,7 +1859,7 @@ class PostgresTxAdapter extends PostgresAdapterBase implements TxAdapter {
|
||||
const userTx: Tx[] = []
|
||||
|
||||
model.forEach((tx) => (tx.modifiedBy === core.account.System && !isPersonAccount(tx) ? systemTx : userTx).push(tx))
|
||||
return systemTx.concat(userTx)
|
||||
return this.stripHash(systemTx.concat(userTx)) as Tx[]
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
||||
@@ -475,7 +475,7 @@ export function parseDocWithProjection<T extends Doc> (
|
||||
domain: string,
|
||||
projection?: Projection<T> | undefined
|
||||
): T {
|
||||
const { workspaceId, data, ...rest } = doc
|
||||
const { workspaceId, data, '%hash%': hash, ...rest } = doc
|
||||
const schema = getSchema(domain)
|
||||
for (const key in rest) {
|
||||
if ((rest as any)[key] === 'NULL' || (rest as any)[key] === null) {
|
||||
|
||||
Reference in New Issue
Block a user