mirror of
https://github.com/hcengineering/platform.git
synced 2024-12-23 03:22:19 +03:00
UBERF-5733: Remove invalid lookup update (#4779)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
parent
a0ceaecbbd
commit
bc86044bed
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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>(
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user