OpenPanel is an open-source web and product analytics platform, an open-source alternative to Mixpanel with optional self-hosting.
fix export api
Carl-Gerhard Lindesvärd1f3b56cdbbac
diff --git a/apps/api/src/controllers/export.controller.ts b/apps/api/src/controllers/export.controller.tsindex 79fc3048e..cc3fb7bed 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.tsindex 47141757a..246636097 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) {