mirror of
https://github.com/hcengineering/platform.git
synced 2024-11-23 14:06:00 +03:00
Fix query cache (#7226)
This commit is contained in:
parent
c91e3c2554
commit
fa8edd5d11
@ -997,6 +997,8 @@ export class LiveQuery implements WithTx, Client {
|
||||
|
||||
const result = q.result
|
||||
|
||||
this.refs.updateDocuments(q, result.getDocs())
|
||||
|
||||
if (bulkUpdate) {
|
||||
this.queriesToUpdate.set(q.id, q)
|
||||
} else {
|
||||
|
@ -1,5 +1,4 @@
|
||||
import {
|
||||
clone,
|
||||
Hierarchy,
|
||||
matchQuery,
|
||||
toFindResult,
|
||||
@ -59,14 +58,17 @@ export class Refs {
|
||||
query: DocumentQuery<Doc>,
|
||||
options?: FindOptions<T>
|
||||
): FindResult<T> | null {
|
||||
const classKey = _class + ':' + JSON.stringify(options?.lookup ?? {})
|
||||
if (typeof query._id === 'string') {
|
||||
const desc = this.getHierarchy().getDescendants(_class)
|
||||
for (const des of desc) {
|
||||
const classKey = des + ':' + JSON.stringify(options?.lookup ?? {})
|
||||
// One document query
|
||||
const doc = this.documentRefs.get(classKey)?.get(query._id)?.doc
|
||||
if (doc !== undefined) {
|
||||
const q = matchQuery([doc], query, _class, this.getHierarchy())
|
||||
if (q.length > 0) {
|
||||
return toFindResult(clone([doc]), 1)
|
||||
return toFindResult(this.getHierarchy().clone([doc]), 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -76,13 +78,14 @@ export class Refs {
|
||||
options?.sort === undefined &&
|
||||
options?.projection === undefined
|
||||
) {
|
||||
const classKey = _class + ':' + JSON.stringify(options?.lookup ?? {})
|
||||
const docs = this.documentRefs.get(classKey)
|
||||
if (docs !== undefined) {
|
||||
const _docs = Array.from(docs.values()).map((it) => it.doc)
|
||||
|
||||
const q = matchQuery(_docs, query, _class, this.getHierarchy())
|
||||
if (q.length > 0) {
|
||||
return toFindResult(clone([q[0]]), 1)
|
||||
return toFindResult(this.getHierarchy().clone([q[0]]), 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -128,8 +128,9 @@ export async function updateIssueRelation (
|
||||
}
|
||||
|
||||
export async function getIssueIdByIdentifier (identifier: string): Promise<Ref<Issue> | undefined> {
|
||||
if (!isIssueId(identifier)) return
|
||||
const client = getClient()
|
||||
const issue = await client.findOne(tracker.class.Issue, { identifier }, { projection: { _id: 1 } })
|
||||
const issue = await client.findOne(tracker.class.Issue, { identifier })
|
||||
|
||||
return issue?._id
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user