Better fix, usage.

This commit is contained in:
Brian Cao 2023-10-20 14:34:02 -05:00
parent 671c9fc791
commit 4153db48d2
2 changed files with 12 additions and 4 deletions

View File

@ -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;
},

View File

@ -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(
@ -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) };
});
});
}