Skip to content

Commit

Permalink
+ ranges: 10d, 60d
Browse files Browse the repository at this point in the history
  • Loading branch information
Raais committed Sep 8, 2024
1 parent 03369e6 commit c898358
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/lib/db/queries/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ import {
in_1y,
in_30d,
in_7d,
in_10d,
in_15d,
in_20d,
in_60d,
in_90d,
in_xdays,
in_cm,
Expand Down Expand Up @@ -176,9 +178,11 @@ const initialRanges: Record<string, any> = {
'_cm': in_cm,
'_lm': in_lm,
'7d': in_7d,
'10d': in_10d,
'15d': in_15d,
'20d': in_20d,
'30d': in_30d,
'60d': in_60d,
'90d': in_90d,
'1y': in_1y,
};
Expand Down
10 changes: 10 additions & 0 deletions src/lib/db/queries/ranges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ export const in_7d = (getCell: any) =>
dayjs().subtract(7, "day")
);

export const in_10d = (getCell: any) =>
dayjs(getCell("date")?.toString(), "YYYY-MM-DD").isAfter(
dayjs().subtract(10, "day")
);

export const in_15d = (getCell: any) =>
dayjs(getCell("date")?.toString(), "YYYY-MM-DD").isAfter(
dayjs().subtract(15, "day")
Expand All @@ -20,6 +25,11 @@ export const in_30d = (getCell: any) =>
dayjs().subtract(30, "day")
);

export const in_60d = (getCell: any) =>
dayjs(getCell("date")?.toString(), "YYYY-MM-DD").isAfter(
dayjs().subtract(60, "day")
);

export const in_90d = (getCell: any) =>
dayjs(getCell("date")?.toString(), "YYYY-MM-DD").isAfter(
dayjs().subtract(90, "day")
Expand Down
4 changes: 4 additions & 0 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ export const rangeToStr : any = {
"1y": "1 Year",
"90d": "90 Days",
"7d": "7 Days",
"10d": "10 Days",
"15d": "15 Days",
"20d": "20 Days",
"30d": "30 Days",
"60d": "60 Days",
"all": "All",
"_lm": "Last Month",
"_cm": "Current Month",
Expand Down Expand Up @@ -99,9 +101,11 @@ function getMostRecentMonthStart(month: number) {
export const rangeData = (range: string) => {
switch (range) {
case "7d": return { from: dayjs().subtract(7, "day"), to: dayjs() };
case "10d": return { from: dayjs().subtract(10, "day"), to: dayjs() };
case "15d": return { from: dayjs().subtract(15, "day"), to: dayjs() };
case "20d": return { from: dayjs().subtract(20, "day"), to: dayjs() };
case "30d": return { from: dayjs().subtract(30, "day"), to: dayjs() };
case "60d": return { from: dayjs().subtract(60, "day"), to: dayjs() };
case "90d": return { from: dayjs().subtract(90, "day"), to: dayjs() };
case "1y": return { from: dayjs().subtract(365, "day"), to: dayjs() };
case "all": return { from: dayjs().subtract(365, "day"), to: dayjs() };
Expand Down

0 comments on commit c898358

Please sign in to comment.