-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Conversation
There was a problem hiding this 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
anduseAggregate
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
andkanbanAggregateOperationFieldMetadataId
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
packages/twenty-front/src/modules/dropdown/components/Dropdown.tsx
Outdated
Show resolved
Hide resolved
packages/twenty-front/src/modules/dropdown/components/Dropdown.tsx
Outdated
Show resolved
Hide resolved
@@ -0,0 +1,12 @@ | |||
import { AggregateContentId } from '@/object-record/record-board/types/AggregateContentId'; | |||
import { createContext } from 'vm'; |
There was a problem hiding this comment.
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'
packages/twenty-front/src/modules/dropdown/components/DropdownContext.tsx
Outdated
Show resolved
Hide resolved
packages/twenty-front/src/modules/dropdown/components/DropdownContext.tsx
Outdated
Show resolved
Hide resolved
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, | ||
}; |
There was a problem hiding this comment.
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
...graphql/workspace-schema-builder/utils/get-available-aggregations-from-object-fields.util.ts
Show resolved
Hide resolved
...-server/src/engine/workspace-manager/workspace-sync-metadata/constants/standard-field-ids.ts
Outdated
Show resolved
Hide resolved
packages/twenty-server/src/modules/view/standard-objects/view.workspace-entity.ts
Show resolved
Hide resolved
@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, | ||
}) |
There was a problem hiding this comment.
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
packages/twenty-front/src/modules/dropdown/components/Dropdown.tsx
Outdated
Show resolved
Hide resolved
...c/modules/object-record/record-board/record-board-column/hooks/useAggregateQueryForColumn.ts
Outdated
Show resolved
Hide resolved
packages/twenty-server/src/modules/view/standard-objects/view.workspace-entity.ts
Show resolved
Hide resolved
Bravo Marie, super cool feature! 🤩 |
packages/twenty-front/src/modules/object-record/graphql/types/RecordGqlConnection.ts
Outdated
Show resolved
Hide resolved
packages/twenty-front/src/modules/object-record/hooks/useAggregate.ts
Outdated
Show resolved
Hide resolved
...front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdown.tsx
Show resolved
Hide resolved
...s/twenty-front/src/modules/object-record/object-options-dropdown/hooks/useOptionsDropdown.ts
Show resolved
Hide resolved
...ges/twenty-front/src/modules/object-record/utils/getAvailableAggregationsFromObjectFields.ts
Show resolved
Hide resolved
...ty-front/src/modules/object-record/utils/getAvailableFieldsForAggregationFromObjectFields.ts
Outdated
Show resolved
Hide resolved
...ty-front/src/modules/object-record/utils/getAvailableFieldsForAggregationFromObjectFields.ts
Outdated
Show resolved
Hide resolved
packages/twenty-front/src/modules/views/hooks/useUpdateViewAggregate.ts
Outdated
Show resolved
Hide resolved
...wenty-server/src/engine/api/graphql/graphql-query-runner/helpers/process-aggregate.helper.ts
Outdated
Show resolved
Hide resolved
0fd5f74
to
4d7c681
Compare
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