Skip to content

Commit

Permalink
Better fix, usage.
Browse files Browse the repository at this point in the history
  • Loading branch information
briancao committed Oct 20, 2023
1 parent 671c9fc commit 4153db4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/pages/api/users/[id]/usage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ export default async (

const usage = websiteUsage.reduce(
(acc, cv) => {
acc.websiteEventUsage += Number(cv.websiteEventUsage);
acc.eventDataUsage += Number(cv.eventDataUsage);
acc.websiteEventUsage += cv.websiteEventUsage;
acc.eventDataUsage += cv.eventDataUsage;

return acc;
},
Expand Down
12 changes: 10 additions & 2 deletions src/queries/analytics/eventData/getEventDataUsage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ export function getEventDataUsage(...args: [websiteIds: string[], startDate: Dat
});
}

function clickhouseQuery(websiteIds: string[], startDate: Date, endDate: Date) {
function clickhouseQuery(
websiteIds: string[],
startDate: Date,
endDate: Date,
): Promise<{ websiteId: string; count: number }[]> {
const { rawQuery } = clickhouse;

return rawQuery(
Expand All @@ -26,5 +30,9 @@ function clickhouseQuery(websiteIds: string[], startDate: Date, endDate: Date) {
startDate,
endDate,
},
);
).then(a => {
return Object.values(a).map(a => {
return { websiteId: a.websiteId, count: Number(a.count) };
});
});
}

0 comments on commit 4153db4

Please sign in to comment.