Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display and update aggregate queries in kanban views #8833

Merged
merged 32 commits into from
Dec 3, 2024

Conversation

ijreilly
Copy link
Collaborator

@ijreilly ijreilly commented Dec 2, 2024

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

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This PR implements aggregate query functionality in kanban views, allowing users to perform operations like count, sum, and average on column data with a new dropdown UI system.

  • Added useAggregateQuery and useAggregate hooks in /packages/twenty-front/src/modules/object-record/hooks/ for handling aggregate operations and GraphQL queries
  • Implemented new dropdown components in /packages/twenty-front/src/modules/dropdown/ with generic type support for managing dropdown state and content
  • Added RecordBoardColumnHeaderAggregateDropdown component in /packages/twenty-front/src/modules/object-record/record-board/record-board-column/components/ for aggregate operation selection
  • Added server-side support with new fields kanbanAggregateOperation and kanbanAggregateOperationFieldMetadataId in /packages/twenty-server/src/modules/view/standard-objects/view.workspace-entity.ts
  • Implemented utility functions in /packages/twenty-front/src/modules/object-record/utils/ for generating aggregate queries and determining available aggregations per field type

52 file(s) reviewed, 63 comment(s)
Edit PR Review Bot Settings | Greptile

@@ -0,0 +1,12 @@
import { AggregateContentId } from '@/object-record/record-board/types/AggregateContentId';
import { createContext } from 'vm';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: incorrect import - should be from 'react' not 'vm'

Comment on lines 77 to 83
acc[`min${capitalize(field.name)}AmountMicros`] = {
type: GraphQLFloat,
description: `Minimal amount contained in the field ${field.name}`,
fromField: field.name,
fromSubField: 'amountMicros',
aggregateOperation: AGGREGATE_OPERATIONS.min,
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: description uses 'Minimal' while NUMBER type uses 'Minimum' - should be consistent across all similar operations

Comment on lines 223 to 229
@WorkspaceField({
standardId: VIEW_STANDARD_FIELD_IDS.kanbanAggregateOperationFieldMetadataId,
type: FieldMetadataType.TEXT,
label: 'Field metadata used for aggregate operation',
description: 'Field metadata used for aggregate operation',
defaultValue: null,
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: using FieldMetadataType.TEXT for an ID field - should probably be UUID type like objectMetadataId

@FelixMalfait
Copy link
Member

Bravo Marie, super cool feature! 🤩

@ijreilly ijreilly enabled auto-merge (squash) December 3, 2024 16:40
@Weiko Weiko force-pushed the aggregate-queries-front branch from 0fd5f74 to 4d7c681 Compare December 3, 2024 20:48
@Weiko Weiko disabled auto-merge December 3, 2024 21:16
@Weiko Weiko merged commit 2fc247c into main Dec 3, 2024
19 checks passed
@Weiko Weiko deleted the aggregate-queries-front branch December 3, 2024 21:46
mdrazak2001 pushed a commit to mdrazak2001/twenty that referenced this pull request Dec 4, 2024
Closes twentyhq#8752, twentyhq#8753, twentyhq#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 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add kanbanAggregateOperation field on view and read it in FE
4 participants