fix: scan all snapshots for oldest timestamp in fetchAllWalletData

snapshotsToDaily returns results sorted newest-first, so allSnaps[0] was
the newest timestamp. This caused fetchPrices to compute a near-zero date
range, resulting in $0 values for all but the most recent rows.

Also removed redundant refreshPrices() call from init flow (fetchAllWalletData
already fetches full-range prices). Added table data flow doc to AGENTS.md.
This commit is contained in:
Dione
2026-06-10 19:52:11 +00:00
parent b659d26ad1
commit e28e66b29f
2 changed files with 23 additions and 3 deletions

View File

@ -1490,7 +1490,12 @@ async function fetchAllWalletData() {
await Promise.all(promises);
const allSnaps = Object.values(addressSnapshots).flat();
if (allSnaps.length > 0) {
const oldestTs = new Date(allSnaps[0].block_timestamp).getTime();
/* snapshots are sorted newest-first; find the oldest */
let oldestTs = Infinity;
allSnaps.forEach(s => {
const t = new Date(s.block_timestamp).getTime();
if (t < oldestTs) oldestTs = t;
});
await fetchPrices(Object.keys(TOKENS), oldestTs);
}
}
@ -1801,10 +1806,9 @@ async function initDashboardGrid() {
const rawPrices = result.result.XXBTZUSD;
btcPriceData = rawPrices.map(item => [item[0] * 1000, parseFloat(item[4])]);
/* Fetch data for all verified wallets */
/* Fetch data for all verified wallets (already fetches full-range prices) */
await fetchAllWalletData();
await refreshPrices();
renderCombinedTable();
const cutoff = getOldestTransactionDate();