Skip to content

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

Merged
merged 1 commit into from
Oct 10, 2023
Merged

fix(site): fix week range for insights #10173

merged 1 commit into from
Oct 10, 2023

Conversation

BrunoQuaresma
Copy link
Collaborator

No description provided.

@BrunoQuaresma BrunoQuaresma self-assigned this Oct 10, 2023
@BrunoQuaresma BrunoQuaresma requested review from a team and Parkreiner and removed request for a team October 10, 2023 12:22
Copy link
Member

@Parkreiner Parkreiner left a 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!

@BrunoQuaresma BrunoQuaresma merged commit 19400d6 into main Oct 10, 2023
@BrunoQuaresma BrunoQuaresma deleted the bq/fix-week-calc branch October 10, 2023 12:33
@github-actions github-actions bot locked and limited conversation to collaborators Oct 10, 2023

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));
Copy link
Member

@mafredri mafredri Oct 10, 2023

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).

Copy link
Collaborator Author

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.

Copy link
Member

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?

Copy link
Collaborator Author

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants