Browse Source

Nc fix/bulk api (#9006)

* fix: bulk aggregation api not working on lookup and user fields

* fix: refactor
pull/8385/merge
Anbarasu 4 months ago committed by GitHub
parent
commit
e7e9fd181a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 57
      packages/nc-gui/composables/useViewGroupBy.ts

57
packages/nc-gui/composables/useViewGroupBy.ts

@ -364,10 +364,27 @@ const [useProvideViewGroupBy, useViewGroupBy] = useInjectionState(
}
if (appInfo.value.ee) {
const aggregationParams = (group.children ?? []).map((child) => ({
const aggregationMap = new Map<string, string>()
const aggregationParams = (group.children ?? []).map((child) => {
try {
const key = JSON.parse(child.key)
if (typeof key === 'object') {
const newKey = Math.random().toString(36).substring(7)
aggregationMap.set(newKey, child.key)
return {
where: calculateNestedWhere(child.nestedIn, where?.value),
alias: newKey,
}
}
} catch (e) {}
return {
where: calculateNestedWhere(child.nestedIn, where?.value),
alias: child.key,
}))
}
})
const aggResponse = !isPublic
? await api.dbDataTableBulkAggregate.dbDataTableBulkAggregate(meta.value!.id, {
@ -382,6 +399,14 @@ const [useProvideViewGroupBy, useViewGroupBy] = useInjectionState(
const child = (group?.children ?? []).find((c) => c.key.toString() === key.toString())
if (child) {
Object.assign(child.aggregations, value)
} else {
const originalKey = aggregationMap.get(key)
if (originalKey) {
const child = (group?.children ?? []).find((c) => c.key.toString() === originalKey.toString())
if (child) {
Object.assign(child.aggregations, value)
}
}
}
})
}
@ -439,10 +464,26 @@ const [useProvideViewGroupBy, useViewGroupBy] = useInjectionState(
if (filteredFields && !filteredFields?.length) return
const aggregationParams = (group.children ?? []).map((child) => ({
const aggregationMap = new Map<string, string>()
const aggregationParams = (group.children ?? []).map((child) => {
try {
const key = JSON.parse(child.key)
if (typeof key === 'object') {
const newKey = Math.random().toString(36).substring(7)
aggregationMap.set(newKey, child.key)
return {
where: calculateNestedWhere(child.nestedIn, where?.value),
alias: newKey,
}
}
} catch (e) {}
return {
where: calculateNestedWhere(child.nestedIn, where?.value),
alias: child.key,
}))
}
})
const response = !isPublic
? await api.dbDataTableBulkAggregate.dbDataTableBulkAggregate(meta.value!.id, {
@ -459,6 +500,14 @@ const [useProvideViewGroupBy, useViewGroupBy] = useInjectionState(
const child = (group.children ?? []).find((c) => c.key.toString() === key.toString())
if (child) {
Object.assign(child.aggregations, value)
} else {
const originalKey = aggregationMap.get(key)
if (originalKey) {
const child = (group.children ?? []).find((c) => c.key.toString() === originalKey.toString())
if (child) {
Object.assign(child.aggregations, value)
}
}
}
})
} catch (e) {

Loading…
Cancel
Save