feat: Allow filtering insight by projectId (#19552)

Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
Co-authored-by: Irénée <ireneea@users.noreply.github.com>
Co-authored-by: r00gm <raul00gm@gmail.com>
This commit is contained in:
Irénée
2025-09-17 09:47:08 +01:00
committed by GitHub
parent 0173d8f707
commit 8086a21eb2
9 changed files with 697 additions and 39 deletions

View File

@@ -17,6 +17,15 @@ describe('InsightsDateFilterDto', () => {
dateRange: 'week',
},
},
{
name: 'valid projectId',
request: {
projectId: '2gQLpmP5V4wOY627',
},
parsedResult: {
projectId: '2gQLpmP5V4wOY627',
},
},
])('should validate $name', ({ request, parsedResult }) => {
const result = InsightsDateFilterDto.safeParse(request);
expect(result.success).toBe(true);
@@ -35,6 +44,13 @@ describe('InsightsDateFilterDto', () => {
},
expectedErrorPath: ['dateRange'],
},
{
name: 'invalid projectId value',
request: {
projectId: 10,
},
expectedErrorPath: ['projectId'],
},
])('should fail validation for $name', ({ request, expectedErrorPath }) => {
const result = InsightsDateFilterDto.safeParse(request);

View File

@@ -77,6 +77,15 @@ describe('ListInsightsWorkflowQueryDto', () => {
sortBy: 'total:asc',
},
},
{
name: 'valid projectId',
request: {
projectId: '2gQLpmP5V4wOY627',
},
parsedResult: {
projectId: '2gQLpmP5V4wOY627',
},
},
])('should validate $name', ({ request, parsedResult }) => {
const result = ListInsightsWorkflowQueryDto.safeParse(request);
expect(result.success).toBe(true);
@@ -111,6 +120,13 @@ describe('ListInsightsWorkflowQueryDto', () => {
},
expectedErrorPath: ['sortBy'],
},
{
name: 'invalid projectId value',
request: {
projectId: 10,
},
expectedErrorPath: ['projectId'],
},
])('should fail validation for $name', ({ request, expectedErrorPath }) => {
const result = ListInsightsWorkflowQueryDto.safeParse(request);

View File

@@ -10,4 +10,5 @@ const dateRange = z.enum(VALID_DATE_RANGE_OPTIONS).optional();
export class InsightsDateFilterDto extends Z.class({
dateRange,
projectId: z.string().optional(),
}) {}

View File

@@ -38,4 +38,5 @@ export class ListInsightsWorkflowQueryDto extends Z.class({
take: createTakeValidator(MAX_ITEMS_PER_PAGE),
dateRange: InsightsDateFilterDto.shape.dateRange,
sortBy: sortByValidator,
projectId: z.string().optional(),
}) {}