Display and update aggregate queries in kanban views (#8833)
Closes #8752, #8753, #8754 Implements usage of aggregate queries in kanban views. https://github.com/user-attachments/assets/732590ca-2785-4c57-82d5-d999a2279e92 TO DO 1. write tests + storybook 2. Fix values displayed should have the same format as defined in number fields + Fix display for amountMicros --------- Co-authored-by: Weiko <corentin@twenty.com>
This commit is contained in:
@ -0,0 +1,7 @@
|
||||
export enum AGGREGATE_OPERATIONS {
|
||||
min = 'MIN',
|
||||
max = 'MAX',
|
||||
avg = 'AVG',
|
||||
sum = 'SUM',
|
||||
count = 'COUNT',
|
||||
}
|
||||
@ -45,6 +45,12 @@ export class GraphqlQuerySelectedFieldsParser {
|
||||
return accumulator;
|
||||
}
|
||||
|
||||
this.aggregateParser.parse(
|
||||
graphqlSelectedFields,
|
||||
fieldMetadataMapByName,
|
||||
accumulator,
|
||||
);
|
||||
|
||||
this.parseRecordField(
|
||||
graphqlSelectedFields,
|
||||
fieldMetadataMapByName,
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import { SelectQueryBuilder } from 'typeorm';
|
||||
|
||||
import { AGGREGATE_OPERATIONS } from 'src/engine/api/graphql/graphql-query-runner/constants/aggregate-operations.constant';
|
||||
import { AggregationField } from 'src/engine/api/graphql/workspace-schema-builder/utils/get-available-aggregations-from-object-fields.util';
|
||||
import { formatColumnNameFromCompositeFieldAndSubfield } from 'src/engine/twenty-orm/utils/format-column-name-from-composite-field-and-subfield.util';
|
||||
import { isDefined } from 'src/utils/is-defined';
|
||||
@ -19,7 +20,7 @@ export class ProcessAggregateHelper {
|
||||
)) {
|
||||
if (
|
||||
!isDefined(aggregatedField?.fromField) ||
|
||||
!isDefined(aggregatedField?.aggregationOperation)
|
||||
!isDefined(aggregatedField?.aggregateOperation)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
@ -28,10 +29,17 @@ export class ProcessAggregateHelper {
|
||||
aggregatedField.fromField,
|
||||
aggregatedField.fromSubField,
|
||||
);
|
||||
const operation = aggregatedField.aggregationOperation;
|
||||
|
||||
if (
|
||||
!Object.values(AGGREGATE_OPERATIONS).includes(
|
||||
aggregatedField.aggregateOperation,
|
||||
)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
queryBuilder.addSelect(
|
||||
`${operation}("${columnName}")`,
|
||||
`${aggregatedField.aggregateOperation}("${columnName}")`,
|
||||
`${aggregatedFieldName}`,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user