-
Notifications
You must be signed in to change notification settings - Fork 887
fix(site): fix week range for insights #10173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense to me, and it looks really clean!
|
||
export const lastWeeks = (numberOfWeeks: number) => { | ||
const now = new Date(); | ||
const startDate = startOfWeek(subWeeks(now, numberOfWeeks)); | ||
const endDate = isSunday(now) ? endOfDay(now) : endOfWeek(subWeeks(now, 1)); | ||
const endDate = startOfDay(subDays(now, 1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this perhaps be just startOfDay(now)
? Let's say we have now = 2023-10-10T15:00:00
(Tuesday), subDays
would put us at 2023-10-09T15:00:00
and startOfDay
would give us 2023-10-09T00:00:00
meaning we're only looking at data up to and including Sunday (whereas including Monday would make sense IMO).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
startOfDay does something like 2023-10-09T23:59:59 but the API only accepts dates as "00:00:00" at the end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I don't understand how startOfDay
gives 23:59, I would assume that's endOfDay
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahhh sorry, I missread your comment. I will give it a try
No description provided.