mirror of
https://github.com/hcengineering/platform.git
synced 2025-05-05 15:02:37 +00: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,
|
AggregateValue,
|
||||||
AggregateValueData,
|
AggregateValueData,
|
||||||
type AnyAttribute,
|
type AnyAttribute,
|
||||||
type Attribute,
|
|
||||||
type Class,
|
type Class,
|
||||||
type Client,
|
type Client,
|
||||||
type Doc,
|
type Doc,
|
||||||
@ -114,14 +113,6 @@ export class ComponentAggregationManager implements AggregationManager {
|
|||||||
}
|
}
|
||||||
return target.filter((it, idx, arr) => arr.indexOf(it) === idx)
|
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 { Analytics } from '@hcengineering/analytics'
|
||||||
import core, {
|
import core, {
|
||||||
Hierarchy,
|
type Hierarchy,
|
||||||
type TxApplyIf,
|
type TxApplyIf,
|
||||||
type TxCUD,
|
type TxCUD,
|
||||||
TxProcessor,
|
TxProcessor,
|
||||||
@ -153,25 +153,7 @@ export class AggregationMiddleware extends BasePresentationMiddleware implements
|
|||||||
|
|
||||||
await this.updateQueryOptions<T>(allAttrs, h, docFields, fquery, finalOptions)
|
await this.updateQueryOptions<T>(allAttrs, h, docFields, fquery, finalOptions)
|
||||||
|
|
||||||
const result = await this.provideFindAll(_class, fquery, finalOptions)
|
return 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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async updateQueryOptions<T extends Doc>(
|
private async updateQueryOptions<T extends Doc>(
|
||||||
|
@ -18,7 +18,6 @@ import {
|
|||||||
Account,
|
Account,
|
||||||
AggregateValue,
|
AggregateValue,
|
||||||
AnyAttribute,
|
AnyAttribute,
|
||||||
Attribute,
|
|
||||||
CategoryType,
|
CategoryType,
|
||||||
Class,
|
Class,
|
||||||
Client,
|
Client,
|
||||||
@ -37,18 +36,17 @@ import {
|
|||||||
Tx,
|
Tx,
|
||||||
TxOperations,
|
TxOperations,
|
||||||
Type,
|
Type,
|
||||||
UXObject,
|
UXObject
|
||||||
WithLookup
|
|
||||||
} from '@hcengineering/core'
|
} from '@hcengineering/core'
|
||||||
|
import { Asset, IntlString, Resource, Status } from '@hcengineering/platform'
|
||||||
|
import { Preference } from '@hcengineering/preference'
|
||||||
import {
|
import {
|
||||||
AnyComponent,
|
AnyComponent,
|
||||||
AnySvelteComponent,
|
AnySvelteComponent,
|
||||||
type LabelAndProps,
|
|
||||||
Location,
|
Location,
|
||||||
Location as PlatformLocation
|
Location as PlatformLocation,
|
||||||
|
type LabelAndProps
|
||||||
} from '@hcengineering/ui'
|
} from '@hcengineering/ui'
|
||||||
import { Asset, IntlString, Resource, Status } from '@hcengineering/platform'
|
|
||||||
import { Preference } from '@hcengineering/preference'
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
@ -377,7 +375,6 @@ export interface Groupping extends Class<Doc> {
|
|||||||
export interface AggregationManager {
|
export interface AggregationManager {
|
||||||
close: () => void
|
close: () => void
|
||||||
notifyTx: (...tx: Tx[]) => Promise<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>>>
|
categorize: (target: Array<Ref<Doc>>, attr: AnyAttribute) => Promise<Array<Ref<Doc>>>
|
||||||
getAttrClass: () => Ref<Class<Doc>>
|
getAttrClass: () => Ref<Class<Doc>>
|
||||||
updateSorting?: (finalOptions: FindOptions<Doc>, attr: AnyAttribute) => Promise<void>
|
updateSorting?: (finalOptions: FindOptions<Doc>, attr: AnyAttribute) => Promise<void>
|
||||||
|
Loading…
Reference in New Issue
Block a user