Include Date fields in aggregate operations on dates (#9479)

Follow-up on https://github.com/twentyhq/twenty/pull/9444/files - I had
forgotten to include Date field types (in addition to DateTime)
This commit is contained in:
Marie
2025-01-09 13:13:21 +01:00
committed by GitHub
parent efb2a59e06
commit c535d21587
13 changed files with 176 additions and 40 deletions

View File

@ -1,7 +1,7 @@
import { GraphQLISODateTime } from '@nestjs/graphql';
import { GraphQLFloat, GraphQLInt, GraphQLScalarType } from 'graphql';
import { capitalize } from 'twenty-shared';
import { capitalize, isFieldMetadataDateKind } from 'twenty-shared';
import { FieldMetadataInterface } from 'src/engine/metadata-modules/field-metadata/interfaces/field-metadata.interface';
@ -75,24 +75,25 @@ export const getAvailableAggregationsFromObjectFields = (
aggregateOperation: AGGREGATE_OPERATIONS.percentageNotEmpty,
};
switch (field.type) {
case FieldMetadataType.DATE_TIME:
acc[`min${capitalize(field.name)}`] = {
type: GraphQLISODateTime,
description: `Earliest date contained in the field ${field.name}`,
fromField: field.name,
fromFieldType: field.type,
aggregateOperation: AGGREGATE_OPERATIONS.min,
};
if (isFieldMetadataDateKind(field.type)) {
acc[`min${capitalize(field.name)}`] = {
type: GraphQLISODateTime,
description: `Earliest date contained in the field ${field.name}`,
fromField: field.name,
fromFieldType: field.type,
aggregateOperation: AGGREGATE_OPERATIONS.min,
};
acc[`max${capitalize(field.name)}`] = {
type: GraphQLISODateTime,
description: `Latest date contained in the field ${field.name}`,
fromField: field.name,
fromFieldType: field.type,
aggregateOperation: AGGREGATE_OPERATIONS.max,
};
break;
acc[`max${capitalize(field.name)}`] = {
type: GraphQLISODateTime,
description: `Latest date contained in the field ${field.name}`,
fromField: field.name,
fromFieldType: field.type,
aggregateOperation: AGGREGATE_OPERATIONS.max,
};
}
switch (field.type) {
case FieldMetadataType.NUMBER:
acc[`min${capitalize(field.name)}`] = {
type: GraphQLFloat,