-
Notifications
You must be signed in to change notification settings - Fork 1
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
Feat/stats api endpoint #320
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.
Ca marche nickel 👌
return NextResponse.json({ error: { message: "Invalid request", errors } }, { status: 400 }); | ||
} else { | ||
const { since: nbIntervals, periodicity } = parsedRequest.data; | ||
let dateBeginOfLastPeriod = new Date(); |
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.
🟢 On pourrait même extraire cette logique dans les helpers de date et avoir un truc du type :
const calculatePeriodDates(periodicity: Periodicity, nbIntervals: number) => {
let dateBeginOfLastPeriod = new Date();
const periodicityMap = {
year: () => startOfYear(new Date()),
month: () => startOfMonth(new Date()),
week: () => startOfWeek(new Date(), { weekStartsOn: 1, locale: fr }),
day: () => startOfDay(new Date()),
};
...
}
src/app/api/stats/route.ts
Outdated
date: Date; | ||
} | ||
|
||
type StatOuput = { |
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.
🟢 petite coquille ici sur StatOutput
No description provided.