feat: update dashboard components and analytics for 7-day summaries
- Modified `ManagerWeeklySummary`, `MetricsTab`, and `ProductivityAnalytics` to reflect a focus on the last 7 days instead of the current week. - Enhanced `ManagerSummaryService` and `MetricsService` to calculate metrics over a sliding 7-day window, improving data relevance. - Added a new utility function `formatDistanceToNow` for better date formatting in French. - Updated comments and documentation to clarify changes in timeframes.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { prisma } from '@/services/core/database';
|
||||
import { startOfWeek, endOfWeek, eachDayOfInterval, format, startOfDay, endOfDay } from 'date-fns';
|
||||
import { eachDayOfInterval, format, startOfDay, endOfDay, startOfWeek, endOfWeek } from 'date-fns';
|
||||
import { fr } from 'date-fns/locale';
|
||||
import { formatDateForAPI, getDayName, getToday, subtractDays } from '@/lib/date-utils';
|
||||
|
||||
@@ -57,11 +57,13 @@ export interface WeeklyMetricsOverview {
|
||||
|
||||
export class MetricsService {
|
||||
/**
|
||||
* Récupère les métriques journalières de la semaine
|
||||
* Récupère les métriques journalières des 7 derniers jours
|
||||
*/
|
||||
static async getWeeklyMetrics(date: Date = getToday()): Promise<WeeklyMetricsOverview> {
|
||||
const weekStart = startOfWeek(date, { weekStartsOn: 1 }); // Lundi
|
||||
const weekEnd = endOfWeek(date, { weekStartsOn: 1 }); // Dimanche
|
||||
// Fenêtre glissante de 7 jours au lieu de semaine calendaire
|
||||
const weekEnd = new Date(date);
|
||||
const weekStart = new Date(date);
|
||||
weekStart.setDate(weekStart.getDate() - 6); // 7 jours en arrière (incluant aujourd'hui)
|
||||
|
||||
// Générer tous les jours de la semaine
|
||||
const daysOfWeek = eachDayOfInterval({ start: weekStart, end: weekEnd });
|
||||
|
||||
Reference in New Issue
Block a user