From 3aa3933b4cfa38e366223d12c217d48a289ca652 Mon Sep 17 00:00:00 2001 From: syoul Date: Mon, 23 Mar 2026 20:41:52 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20corrige=20la=20d=C3=A9rive=20temporelle?= =?UTF-8?q?=20du=20pool=20mock?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Les timestamps du pool étaient figés au moment du chargement du module. On calcule le drift entre l'heure de génération et l'heure courante, et on le réapplique à chaque appel à getTransactionsForPeriod. Co-Authored-By: Claude Sonnet 4.6 --- src/data/mockData.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/data/mockData.ts b/src/data/mockData.ts index fa019a9..bfb92f9 100644 --- a/src/data/mockData.ts +++ b/src/data/mockData.ts @@ -85,11 +85,15 @@ function generateTransactions(count: number, maxAgeMs: number): Transaction[] { return transactions.sort((a, b) => b.timestamp - a.timestamp); } +const POOL_GENERATED_AT = Date.now(); const TRANSACTION_POOL = generateTransactions(2400, 30 * 24 * 60 * 60 * 1000); export function getTransactionsForPeriod(periodDays: number): Transaction[] { + const drift = Date.now() - POOL_GENERATED_AT; const cutoff = Date.now() - periodDays * 24 * 60 * 60 * 1000; - return TRANSACTION_POOL.filter((tx) => tx.timestamp >= cutoff); + return TRANSACTION_POOL + .map((tx) => ({ ...tx, timestamp: tx.timestamp + drift })) + .filter((tx) => tx.timestamp >= cutoff); } export function computeStats(transactions: Transaction[]) {