Skip to content

Commit

Permalink
+ ranges: 15d, 20d
Browse files Browse the repository at this point in the history
  • Loading branch information
Raais committed Sep 8, 2024
1 parent a1e540b commit 03369e6
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,6 +11,8 @@ import {
in_1y,
in_30d,
in_7d,
in_15d,
in_20d,
in_90d,
in_xdays,
in_cm,
Expand Down Expand Up @@ -174,6 +176,8 @@ const initialRanges: Record<string, any> = {
'_cm': in_cm,
'_lm': in_lm,
'7d': in_7d,
'15d': in_15d,
'20d': in_20d,
'30d': in_30d,
'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,16 @@ export const in_7d = (getCell: any) =>
dayjs().subtract(7, "day")
);

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

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

export const in_30d = (getCell: any) =>
dayjs(getCell("date")?.toString(), "YYYY-MM-DD").isAfter(
dayjs().subtract(30, "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,6 +62,8 @@ export const rangeToStr : any = {
"1y": "1 Year",
"90d": "90 Days",
"7d": "7 Days",
"15d": "15 Days",
"20d": "20 Days",
"30d": "30 Days",
"all": "All",
"_lm": "Last Month",
Expand Down Expand Up @@ -97,6 +99,8 @@ function getMostRecentMonthStart(month: number) {
export const rangeData = (range: string) => {
switch (range) {
case "7d": return { from: dayjs().subtract(7, "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 "90d": return { from: dayjs().subtract(90, "day"), to: dayjs() };
case "1y": return { from: dayjs().subtract(365, "day"), to: dayjs() };
Expand Down

0 comments on commit 03369e6

Please sign in to comment.