mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-19 23:00:13 +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.
|
// 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 > 0) {
|
||||||
if (trigger) {
|
if (trigger) {
|
||||||
this.triggerCounter = 5 // Schedule 5 refreshes on every 5 seconds.
|
this.triggerCounter = 2 // Schedule 2 refreshes on every 10 seconds.
|
||||||
}
|
}
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.triggerCounter--
|
this.triggerCounter--
|
||||||
void this.checkUpdateEvents(evt, false)
|
void this.checkUpdateEvents(evt, false)
|
||||||
}, 5000)
|
}, 10000)
|
||||||
}
|
}
|
||||||
|
|
||||||
const h = this.client.getHierarchy()
|
const h = this.client.getHierarchy()
|
||||||
@ -1319,6 +1319,15 @@ export class LiveQuery implements WithTx, Client {
|
|||||||
Analytics.handleError(err)
|
Analytics.handleError(err)
|
||||||
console.error(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
|
// Just assign scores based on idex
|
||||||
result.forEach((it) => {
|
result.forEach((it) => {
|
||||||
const idDoc = indexedDocMap.get(it._id)
|
const idDoc = indexedDocMap.get(it._id)
|
||||||
const { _score, id, _class, ...extra } = idDoc as any
|
const { _score } = idDoc as any
|
||||||
it.$source = {
|
it.$source = {
|
||||||
...extra,
|
|
||||||
$score: _score
|
$score: _score
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
if (scoreSearch !== undefined) {
|
if (scoreSearch !== undefined) {
|
||||||
result.sort((a, b) => scoreSearch * ((a.$source?.$score ?? 0) - (b.$source?.$score ?? 0)))
|
result.sort((a, b) => scoreSearch * ((a.$source?.$score ?? 0) - (b.$source?.$score ?? 0)))
|
||||||
}
|
|
||||||
if (scoreSearch !== undefined) {
|
|
||||||
if (options?.limit !== undefined && options?.limit < result.length) {
|
if (options?.limit !== undefined && options?.limit < result.length) {
|
||||||
result = toFindResult(result.slice(0, options?.limit), result.total)
|
result = toFindResult(result.slice(0, options?.limit), result.total)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user