Skip to content

Commit a938351

Browse files
committed
fix: organization timeseries should use activityRelations and for members it should use postgres
Signed-off-by: Uroš Marolt <uros@marolt.me>
1 parent cf147f4 commit a938351

2 files changed

Lines changed: 5 additions & 6 deletions

File tree

services/apps/cache_worker/src/activities/dashboard-cache/refreshDashboardCache.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export async function getNewMembersTimeseries(
6969
export async function getActiveMembersTimeseries(
7070
params: IQueryTimeseriesParams,
7171
): Promise<ITimeseriesDatapoint[]> {
72-
return getTimeseriesOfActiveMembers(dbStoreQx(qdb), params)
72+
return getTimeseriesOfActiveMembers(dbStoreQx(svc.postgres.reader), params)
7373
}
7474

7575
export async function getNewOrganizationsTimeseries(
@@ -81,7 +81,7 @@ export async function getNewOrganizationsTimeseries(
8181
export async function getActiveOrganizationsTimeseries(
8282
params: IQueryTimeseriesParams,
8383
): Promise<ITimeseriesDatapoint[]> {
84-
return getTimeseriesOfActiveOrganizations(dbStoreQx(qdb), params)
84+
return getTimeseriesOfActiveOrganizations(dbStoreQx(svc.postgres.reader), params)
8585
}
8686

8787
export async function getActivitiesNumber(params: IQueryTimeseriesParams): Promise<number> {

services/libs/data-access-layer/src/organizations/organizations.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -471,10 +471,9 @@ export async function getTimeseriesOfActiveOrganizations(
471471
const query = `
472472
SELECT
473473
COUNT_DISTINCT("organizationId") AS count,
474-
DATE_TRUNC('day', timestamp)
475-
FROM activities
476-
WHERE "deletedAt" IS NULL
477-
AND "organizationId" IS NOT NULL
474+
DATE_TRUNC('day', timestamp) as date
475+
FROM "activityRelations"
476+
WHERE "organizationId" IS NOT NULL
478477
${params.segmentIds ? 'AND "segmentId" IN ($(segmentIds:csv))' : ''}
479478
AND timestamp >= $(startDate)
480479
AND timestamp < $(endDate)

0 commit comments

Comments
 (0)