mirror of
https://github.com/nocodb/nocodb.git
synced 2026-05-01 02:07:07 +00:00
28 lines
942 B
TypeScript
28 lines
942 B
TypeScript
import { type ColumnType, type SerializerOrParserFnProps, formatAggregation, formatBytes } from 'nocodb-sdk'
|
|
import { aggregationCache } from '../components/smartsheet/grid/canvas/utils/canvas'
|
|
|
|
export { formatBytes }
|
|
|
|
export const getFormattedAggrationValue = (
|
|
aggregation: string,
|
|
value: any,
|
|
col: ColumnType,
|
|
cacheKeyPath: string[] = [],
|
|
columnHelperParams?: SerializerOrParserFnProps['params'],
|
|
) => {
|
|
const cacheKey = `${col.id}-${col.uidt}-${aggregation}-${value?.toString()}-${cacheKeyPath.join('-')}-${
|
|
columnHelperParams?.meta?.columnsHash
|
|
}`
|
|
|
|
const cacheValue = aggregationCache.get(cacheKey)
|
|
if (!ncIsUndefined(cacheValue)) {
|
|
return isValidValue(cacheValue) ? cacheValue : undefined
|
|
}
|
|
|
|
const aggregationValue = formatAggregation(aggregation, value, col, columnHelperParams)
|
|
|
|
aggregationCache.set(cacheKey, aggregationValue)
|
|
|
|
return isValidValue(aggregationValue) ? aggregationValue : undefined
|
|
}
|