2 Commits

Author SHA1 Message Date
syoul 3aa3933b4c fix: corrige la dérive temporelle du pool mock
ci/woodpecker/push/woodpecker Pipeline was successful
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 <noreply@anthropic.com>
2026-03-23 20:41:52 +01:00
syoul 2ed51243d2 chore: ajoute docs-bugs/ au .gitignore
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-23 20:39:15 +01:00
2 changed files with 6 additions and 1 deletions
+1
View File
@@ -30,3 +30,4 @@ dist-ssr
/docs-plan/
/docs-syoul/
/docs-bugs/
+5 -1
View File
@@ -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[]) {