UBERF-4384: Update space from attributes (#4049)

Signed-off-by: Maxim Karmatskikh <mkarmatskih@gmail.com>
This commit is contained in:
Maksim Karmatskikh 2023-11-24 10:53:46 +01:00 committed by GitHub
parent d2604f4f23
commit 133e750e9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View File

@ -303,4 +303,9 @@ function updateDoc2Elastic (
}
}
}
const spaceKey = docKey('space', { _class: core.class.Doc })
if (doc[spaceKey] !== undefined) {
doc.space = doc[spaceKey]
}
}

View File

@ -31,7 +31,8 @@ import core, {
_getOperator,
setObjectValue,
toFindResult,
versionToString
versionToString,
docKey
} from '@hcengineering/core'
import { DbAdapter } from '../adapter'
import { RateLimitter } from '../limitter'
@ -145,7 +146,7 @@ export class FullTextIndexPipeline implements FullTextPipeline {
}
}
updateDoc<T extends Doc>(doc: T, tx: DocumentUpdate<T>, updateDate: boolean): T {
updateDoc (doc: DocIndexState, tx: DocumentUpdate<DocIndexState>, updateDate: boolean): DocIndexState {
for (const key in tx) {
if (key.startsWith('$')) {
const operator = _getOperator(key)
@ -154,6 +155,12 @@ export class FullTextIndexPipeline implements FullTextPipeline {
setObjectValue(key, doc, (tx as any)[key])
}
}
const spaceKey = docKey('space', { _class: core.class.Doc })
if (doc.attributes !== undefined && doc.attributes[spaceKey] !== undefined) {
doc.space = doc.attributes[spaceKey]
}
if (updateDate) {
doc.modifiedBy = core.account.System
doc.modifiedOn = Date.now()