diff --git a/apps/api/src/controllers/export.controller.ts b/apps/api/src/controllers/export.controller.ts index 79fc3048..cc3fb7be 100644 --- a/apps/api/src/controllers/export.controller.ts +++ b/apps/api/src/controllers/export.controller.ts @@ -69,6 +69,12 @@ const eventsScheme = z.object({ end: z.coerce.string().optional(), page: z.coerce.number().optional().default(1), limit: z.coerce.number().optional().default(50), + includes: z + .preprocess( + (arg) => (typeof arg === 'string' ? [arg] : arg), + z.array(z.string()) + ) + .optional(), }); export async function events( @@ -103,7 +109,7 @@ export async function events( cursor, take, meta: false, - profile: true, + profile: query.data.includes?.includes('profile'), }; const [data, totalCount] = await Promise.all([ diff --git a/packages/db/src/services/event.service.ts b/packages/db/src/services/event.service.ts index 47141757..24663609 100644 --- a/packages/db/src/services/event.service.ts +++ b/packages/db/src/services/event.service.ts @@ -361,7 +361,7 @@ export async function getEventList({ } if (startDate && endDate) { - sb.where.created_at = `toDate(created_at) BETWEEN '${formatClickhouseDate(startDate)}' AND '${formatClickhouseDate(endDate)}'`; + sb.where.created_at = `toDate(created_at) BETWEEN toDate('${formatClickhouseDate(startDate)}') AND toDate('${formatClickhouseDate(endDate)}')`; } if (events && events.length > 0) { @@ -403,7 +403,7 @@ export async function getEventsCount({ } if (startDate && endDate) { - sb.where.created_at = `created_at BETWEEN '${formatClickhouseDate(startDate)}' AND '${formatClickhouseDate(endDate)}'`; + sb.where.created_at = `toDate(created_at) BETWEEN toDate('${formatClickhouseDate(startDate)}') AND toDate('${formatClickhouseDate(endDate)}')`; } if (events && events.length > 0) {