UBERF-5733: Remove invalid lookup update (#4779)

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev 2024-02-27 17:31:04 +07:00 committed by GitHub
parent a0ceaecbbd
commit bc86044bed
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 37 deletions

View File

@ -17,7 +17,6 @@ import {
AggregateValue,
AggregateValueData,
type AnyAttribute,
type Attribute,
type Class,
type Client,
type Doc,
@ -114,14 +113,6 @@ export class ComponentAggregationManager implements AggregationManager {
}
return target.filter((it, idx, arr) => arr.indexOf(it) === idx)
}
async updateLookup (resultDoc: WithLookup<Doc>, attr: Attribute<Doc>): Promise<void> {
const value = (resultDoc as any)[attr.name]
const doc = (await this.getManager()).getIdMap().get(value)
if (doc !== undefined) {
;(resultDoc.$lookup as any)[attr.name] = doc
}
}
}
/**

View File

@ -1,6 +1,6 @@
import { Analytics } from '@hcengineering/analytics'
import core, {
Hierarchy,
type Hierarchy,
type TxApplyIf,
type TxCUD,
TxProcessor,
@ -153,25 +153,7 @@ export class AggregationMiddleware extends BasePresentationMiddleware implements
await this.updateQueryOptions<T>(allAttrs, h, docFields, fquery, finalOptions)
const result = await this.provideFindAll(_class, fquery, finalOptions)
// We need to add $
if (docFields.length > 0) {
// We need to update $lookup for doc fields and provide $doc group fields.
for (const attr of docFields) {
for (const r of result) {
const resultDoc = Hierarchy.toDoc(r)
if (resultDoc.$lookup === undefined) {
resultDoc.$lookup = {}
}
const mgr = await this.getAggregationManager((attr.type as RefTo<Doc>).to)
if (mgr !== undefined) {
await mgr.updateLookup(resultDoc, attr)
}
}
}
}
return result
return await this.provideFindAll(_class, fquery, finalOptions)
}
private async updateQueryOptions<T extends Doc>(

View File

@ -18,7 +18,6 @@ import {
Account,
AggregateValue,
AnyAttribute,
Attribute,
CategoryType,
Class,
Client,
@ -37,18 +36,17 @@ import {
Tx,
TxOperations,
Type,
UXObject,
WithLookup
UXObject
} from '@hcengineering/core'
import { Asset, IntlString, Resource, Status } from '@hcengineering/platform'
import { Preference } from '@hcengineering/preference'
import {
AnyComponent,
AnySvelteComponent,
type LabelAndProps,
Location,
Location as PlatformLocation
Location as PlatformLocation,
type LabelAndProps
} from '@hcengineering/ui'
import { Asset, IntlString, Resource, Status } from '@hcengineering/platform'
import { Preference } from '@hcengineering/preference'
/**
* @public
@ -377,7 +375,6 @@ export interface Groupping extends Class<Doc> {
export interface AggregationManager {
close: () => void
notifyTx: (...tx: Tx[]) => Promise<void>
updateLookup: (resultDoc: WithLookup<Doc>, attr: Attribute<Doc>) => Promise<void>
categorize: (target: Array<Ref<Doc>>, attr: AnyAttribute) => Promise<Array<Ref<Doc>>>
getAttrClass: () => Ref<Class<Doc>>
updateSorting?: (finalOptions: FindOptions<Doc>, attr: AnyAttribute) => Promise<void>