Compare commits
2 Commits
7975abc619
...
3aa3933b4c
| Author | SHA1 | Date | |
|---|---|---|---|
| 3aa3933b4c | |||
| 2ed51243d2 |
@@ -30,3 +30,4 @@ dist-ssr
|
||||
|
||||
/docs-plan/
|
||||
/docs-syoul/
|
||||
/docs-bugs/
|
||||
|
||||
@@ -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[]) {
|
||||
|
||||
Reference in New Issue
Block a user