Skip to content

Commit

Permalink
chore: format
Browse files Browse the repository at this point in the history
  • Loading branch information
mbhrznr committed Jun 28, 2023
1 parent 3a517d5 commit 5118fd0
Showing 1 changed file with 42 additions and 13 deletions.
55 changes: 42 additions & 13 deletions utils/db_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,15 @@ Deno.test("[db] getAnalyticsMetricsSince", async () => {
const yesterday = new Date(+today - DAY);
const twoDaysAgo = new Date(+today - 2 * DAY);

const visitsCountToday = Number((await getVisitsCountByDay(today))?.valueOf() ?? 0n);
const visitsCountYesterday = Number((await getVisitsCountByDay(yesterday))?.valueOf() ?? 0n)
const visitsCountTwoDaysAgo = Number((await getVisitsCountByDay(twoDaysAgo))?.valueOf() ?? 0n)

const visitsCountToday = Number(
(await getVisitsCountByDay(today))?.valueOf() ?? 0n,
);
const visitsCountYesterday = Number(
(await getVisitsCountByDay(yesterday))?.valueOf() ?? 0n,
);
const visitsCountTwoDaysAgo = Number(
(await getVisitsCountByDay(twoDaysAgo))?.valueOf() ?? 0n,
);

assertEquals(await getAnalyticsMetricsSince("", 0), {
dates: [],
Expand All @@ -288,7 +293,11 @@ Deno.test("[db] getAnalyticsMetricsSince", async () => {
});
assertEquals(await getAnalyticsMetricsSince("visits_count", DAY * 3), {
dates: [formatDate(twoDaysAgo), formatDate(yesterday), formatDate(today)],
metricsValue: [visitsCountTwoDaysAgo, visitsCountYesterday + 1, visitsCountToday + 2],
metricsValue: [
visitsCountTwoDaysAgo,
visitsCountYesterday + 1,
visitsCountToday + 2,
],
});
});

Expand All @@ -297,13 +306,25 @@ Deno.test("[db] getManyAnalyticsMetricsSince", async () => {
const yesterday = new Date(+today - DAY);
const twoDaysAgo = new Date(+today - 2 * DAY);

const usersCountToday = Number((await getUsersCountByDay(today))?.valueOf() ?? 0n);
const usersCountYesterday = Number((await getUsersCountByDay(yesterday))?.valueOf() ?? 0n);
const usersCountTwoDaysAgo = Number((await getUsersCountByDay(twoDaysAgo))?.valueOf() ?? 0n);
const usersCountToday = Number(
(await getUsersCountByDay(today))?.valueOf() ?? 0n,
);
const usersCountYesterday = Number(
(await getUsersCountByDay(yesterday))?.valueOf() ?? 0n,
);
const usersCountTwoDaysAgo = Number(
(await getUsersCountByDay(twoDaysAgo))?.valueOf() ?? 0n,
);

const itemsCountToday = Number((await getItemsCountByDay(today))?.valueOf() ?? 0n);
const itemsCountYesterday = Number((await getItemsCountByDay(yesterday))?.valueOf() ?? 0n);
const itemsCountTwoDaysAgo = Number((await getItemsCountByDay(twoDaysAgo))?.valueOf() ?? 0n);
const itemsCountToday = Number(
(await getItemsCountByDay(today))?.valueOf() ?? 0n,
);
const itemsCountYesterday = Number(
(await getItemsCountByDay(yesterday))?.valueOf() ?? 0n,
);
const itemsCountTwoDaysAgo = Number(
(await getItemsCountByDay(twoDaysAgo))?.valueOf() ?? 0n,
);

assertEquals(await getManyAnalyticsMetricsSince([], 0), []);
assertEquals(
Expand All @@ -330,10 +351,18 @@ Deno.test("[db] getManyAnalyticsMetricsSince", async () => {
await getManyAnalyticsMetricsSince(["users_count", "items_count"], DAY * 3),
[{
dates: [formatDate(twoDaysAgo), formatDate(yesterday), formatDate(today)],
metricsValue: [usersCountTwoDaysAgo, usersCountYesterday, usersCountToday],
metricsValue: [
usersCountTwoDaysAgo,
usersCountYesterday,
usersCountToday,
],
}, {
dates: [formatDate(twoDaysAgo), formatDate(yesterday), formatDate(today)],
metricsValue: [itemsCountTwoDaysAgo, itemsCountYesterday, itemsCountToday],
metricsValue: [
itemsCountTwoDaysAgo,
itemsCountYesterday,
itemsCountToday,
],
}],
);
});

0 comments on commit 5118fd0

Please sign in to comment.