Skip to content
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

Merged
merged 11 commits into from
Jan 14, 2025
Merged

Feat/stats api endpoint #320

merged 11 commits into from
Jan 14, 2025

Conversation

rtaieb
Copy link
Contributor

@rtaieb rtaieb commented Dec 27, 2024

No description provided.

@rtaieb rtaieb requested a review from mehdilouraoui January 6, 2025 12:08
Copy link
Contributor

@mehdilouraoui mehdilouraoui left a 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();
Copy link
Contributor

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()),
  };
  ...
}  

date: Date;
}

type StatOuput = {
Copy link
Contributor

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

Copy link

@mehdilouraoui mehdilouraoui merged commit 968779d into main Jan 14, 2025
5 checks passed
@mehdilouraoui mehdilouraoui deleted the feat/stats-api-endpoint branch January 14, 2025 10:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants