First step of https://github.com/twentyhq/twenty/issues/6868 Adds min.., max.. queries for DATETIME fields adds min.., max.., avg.., sum.. queries for NUMBER fields (count distinct operation and composite fields such as CURRENCY handling will be dealt with in a future PR) <img width="1422" alt="Capture d’écran 2024-11-06 à 15 48 46" src="https://github.com/user-attachments/assets/4bcdece0-ad3e-4536-9720-fe4044a36719"> --------- Co-authored-by: Charles Bochet <charles@twenty.com> Co-authored-by: Weiko <corentin@twenty.com>
This commit is contained in:
@ -1,11 +1,13 @@
|
||||
import deepEqual from 'deep-equal';
|
||||
|
||||
import { Record } from 'src/engine/api/graphql/workspace-query-builder/interfaces/record.interface';
|
||||
import { ObjectRecord } from 'src/engine/api/graphql/workspace-query-builder/interfaces/object-record.interface';
|
||||
|
||||
import { BaseWorkspaceEntity } from 'src/engine/twenty-orm/base.workspace-entity';
|
||||
|
||||
export const objectRecordChangedProperties = <
|
||||
PRecord extends Partial<Record | BaseWorkspaceEntity> = Partial<Record>,
|
||||
PRecord extends Partial<
|
||||
ObjectRecord | BaseWorkspaceEntity
|
||||
> = Partial<ObjectRecord>,
|
||||
>(
|
||||
oldRecord: PRecord,
|
||||
newRecord: PRecord,
|
||||
|
||||
@ -1,23 +1,19 @@
|
||||
import deepEqual from 'deep-equal';
|
||||
|
||||
import { Record as IRecord } from 'src/engine/api/graphql/workspace-query-builder/interfaces/record.interface';
|
||||
import { ObjectRecord } from 'src/engine/api/graphql/workspace-query-builder/interfaces/object-record.interface';
|
||||
import { ObjectMetadataInterface } from 'src/engine/metadata-modules/field-metadata/interfaces/object-metadata.interface';
|
||||
|
||||
import { FieldMetadataType } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
|
||||
|
||||
export const objectRecordChangedValues = (
|
||||
oldRecord: Partial<IRecord>,
|
||||
newRecord: Partial<IRecord>,
|
||||
oldRecord: Partial<ObjectRecord>,
|
||||
newRecord: Partial<ObjectRecord>,
|
||||
updatedKeys: string[] | undefined,
|
||||
objectMetadata: ObjectMetadataInterface,
|
||||
objectMetadataItem: ObjectMetadataInterface,
|
||||
) => {
|
||||
const fieldsByKey = new Map(
|
||||
objectMetadata.fields.map((field) => [field.name, field]),
|
||||
);
|
||||
|
||||
return Object.keys(newRecord).reduce(
|
||||
(acc, key) => {
|
||||
const field = fieldsByKey.get(key);
|
||||
const field = objectMetadataItem.fields.find((f) => f.name === key);
|
||||
const oldRecordValue = oldRecord[key];
|
||||
const newRecordValue = newRecord[key];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user