Skip to content

OpenPanel is an open-source web and product analytics platform, an open-source alternative to Mixpanel with optional self-hosting.

fix(db): count rows broken

Carl-Gerhard Lindesvärd80fa34469e10
diff --git a/packages/db/src/services/organization.service.ts b/packages/db/src/services/organization.service.ts
index a1843bfca..3a9f6895a 100644
--- a/packages/db/src/services/organization.service.ts
+++ b/packages/db/src/services/organization.service.ts
@@ -203,7 +203,7 @@ export async function getOrganizationBillingEventsCount(
sb.select.count = 'COUNT(*) AS count';
sb.where.projectIds = `project_id IN (${organization.projects.map((project) => escape(project.id)).join(',')})`;
- sb.where.createdAt = `BETWEEN ${escape(formatClickhouseDate(organization.subscriptionCurrentPeriodStart))} AND ${escape(formatClickhouseDate(organization.subscriptionCurrentPeriodEnd))}`;
+ sb.where.createdAt = `created_at BETWEEN ${escape(formatClickhouseDate(organization.subscriptionCurrentPeriodStart))} AND ${escape(formatClickhouseDate(organization.subscriptionCurrentPeriodEnd))}`;
const res = await chQuery<{ count: number }>(getSql());
return res[0]?.count;