-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Group by common table expressions support WiP
- Loading branch information
Showing
4 changed files
with
129 additions
and
60 deletions.
There are no files selected for viewing
35 changes: 34 additions & 1 deletion
35
...twenty-front/src/modules/object-record/record-field/types/guards/isFieldFieldPathValue.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,40 @@ | ||
import { FieldJsonValue } from '@/object-record/record-field/types/FieldMetadata'; | ||
import { z } from 'zod'; | ||
|
||
const chartQuerySchema = z | ||
.object({ | ||
sourceObjectMetadataId: z.string().nullable(), | ||
target: z | ||
.object({ | ||
relationFieldMetadataIds: z.array(z.string()).nullable(), | ||
measureFieldMetadataId: z.string().nullable(), | ||
measure: z.string().nullable(), | ||
}) | ||
.partial(), | ||
groupBy: z | ||
.object({ | ||
relationFieldMetadataIds: z.array(z.string()).nullable(), | ||
measureFieldMetadataId: z.string().nullable(), | ||
measure: z.string().nullable(), | ||
groups: z | ||
.array( | ||
z | ||
.object({ upperLimit: z.number(), lowerLimit: z.number() }) | ||
.partial(), | ||
) | ||
.nullable(), | ||
includeNulls: z.boolean().nullable(), | ||
}) | ||
.partial(), | ||
// Later: Filters should be included in the CHART_QUERY UI => better to also store them in CHART_QUERY JSON? | ||
}) | ||
.partial(); | ||
|
||
export type ChartQuery = z.infer<typeof chartQuerySchema>; | ||
|
||
const fieldPathSchema = z.array(z.string()).nullable(); | ||
|
||
export const isFieldFieldPathValue = ( | ||
fieldValue: unknown, | ||
): fieldValue is FieldJsonValue => | ||
z.array(z.string()).nullable().safeParse(fieldValue).success; | ||
fieldPathSchema.safeParse(fieldValue).success; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
packages/twenty-server/src/engine/core-modules/chart/types/chart-query.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { ChartQueryMeasure } from 'src/modules/charts/standard-objects/chart.workspace-entity'; | ||
|
||
export interface ChartQuery { | ||
sourceObjectMetadataId?: string; | ||
target?: { | ||
relationFieldMetadataIds?: string[]; | ||
measureFieldMetadataId?: string; | ||
measure?: ChartQueryMeasure; | ||
}; | ||
groupBy?: { | ||
relationFieldMetadataIds?: string[]; | ||
measureFieldMetadataId?: string; | ||
measure?: ChartQueryMeasure; | ||
groups?: { upperLimit: number; lowerLimit: number }[]; | ||
includeNulls?: boolean; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters