mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-12 19:30:52 +00:00
Query fixes (#5660)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
8c6a5f4e9d
commit
dff3ccd4a4
@ -1296,12 +1296,12 @@ export class LiveQuery implements WithTx, Client {
|
||||
// We need to add trigger once more, since elastic could have a huge lag with document availability.
|
||||
if (trigger || this.triggerCounter > 0) {
|
||||
if (trigger) {
|
||||
this.triggerCounter = 5 // Schedule 5 refreshes on every 5 seconds.
|
||||
this.triggerCounter = 2 // Schedule 2 refreshes on every 10 seconds.
|
||||
}
|
||||
setTimeout(() => {
|
||||
this.triggerCounter--
|
||||
void this.checkUpdateEvents(evt, false)
|
||||
}, 5000)
|
||||
}, 10000)
|
||||
}
|
||||
|
||||
const h = this.client.getHierarchy()
|
||||
@ -1319,6 +1319,15 @@ export class LiveQuery implements WithTx, Client {
|
||||
Analytics.handleError(err)
|
||||
console.error(err)
|
||||
}
|
||||
} else {
|
||||
const queries = this.queries.get(q._class)
|
||||
const pos = queries?.indexOf(q) ?? -1
|
||||
if (pos >= 0 && queries !== undefined) {
|
||||
queries.splice(pos, 1)
|
||||
if (queries?.length === 0) {
|
||||
this.queries.delete(q._class)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -248,16 +248,13 @@ export class FullTextIndex implements WithFind {
|
||||
// Just assign scores based on idex
|
||||
result.forEach((it) => {
|
||||
const idDoc = indexedDocMap.get(it._id)
|
||||
const { _score, id, _class, ...extra } = idDoc as any
|
||||
const { _score } = idDoc as any
|
||||
it.$source = {
|
||||
...extra,
|
||||
$score: _score
|
||||
}
|
||||
})
|
||||
if (scoreSearch !== undefined) {
|
||||
result.sort((a, b) => scoreSearch * ((a.$source?.$score ?? 0) - (b.$source?.$score ?? 0)))
|
||||
}
|
||||
if (scoreSearch !== undefined) {
|
||||
if (options?.limit !== undefined && options?.limit < result.length) {
|
||||
result = toFindResult(result.slice(0, options?.limit), result.total)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user