Add composite fields to aggregation (#8518)
## Context This PR introduces a first aggregation for a composite field ## Test <img width="1074" alt="Screenshot 2024-11-15 at 15 37 05" src="https://github.com/user-attachments/assets/db2563f9-26b7-421f-9431-48fc13bce49e">
This commit is contained in:
@ -19,6 +19,7 @@ export type AggregationField = {
|
||||
type: GraphQLScalarType;
|
||||
description: string;
|
||||
fromField: string;
|
||||
fromSubField?: string;
|
||||
aggregationOperation: AGGREGATION_OPERATIONS;
|
||||
};
|
||||
|
||||
@ -79,6 +80,16 @@ export const getAvailableAggregationsFromObjectFields = (
|
||||
};
|
||||
}
|
||||
|
||||
if (field.type === FieldMetadataType.CURRENCY) {
|
||||
acc[`avg${capitalize(field.name)}AmountMicros`] = {
|
||||
type: GraphQLFloat,
|
||||
description: `Average amount contained in the field ${field.name}`,
|
||||
fromField: field.name,
|
||||
fromSubField: 'amountMicros',
|
||||
aggregationOperation: AGGREGATION_OPERATIONS.avg,
|
||||
};
|
||||
}
|
||||
|
||||
return acc;
|
||||
}, {});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user