diff options
| author | Adam Soltys <[email protected]> | 2026-11-25 15:11:52 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-11-25 15:11:52 -0700 |
| commit | 699fcf7e5c2f17adcef730951ad013ec3f7d4277 (patch) | |
| tree | e711e63b3d64341a6abd236616e79497c39b79d2 | |
| parent | e171361854d1e285a76696dcf3086650e02ed8d3 (diff) | |
| download | coinos-server-699fcf7e5c2f17adcef730951ad013ec3f7d4277.tar.gz coinos-server-699fcf7e5c2f17adcef730951ad013ec3f7d4277.zip | |
funds: include archived and pre-rotation history in GET /fund/:id
A fund's older payments live in the archive, and funds whose id was
rotated keep that history under their previous id, so the fund page only
showed the most recent entries. Merge the live and archived lists for both
ids (fund:rotatedFrom:<id> maps a rotated fund back to its previous id) and
sort newest first.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VMan6W9CsdxmhFrfaKNVHU
| -rw-r--r-- | routes/payments.ts | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/routes/payments.ts b/routes/payments.ts index f9be4c34..86f34cc5 100644 --- a/routes/payments.ts +++ b/routes/payments.ts @@ -302,15 +302,31 @@ export default { if (typeof amount === "undefined" || amount === null) return bail(res, "fund not found"); - let payments = (await db.lRange(`fund:${fid}:payments`, 0, -1)) || []; - payments = await Promise.all(payments.map((hash) => gf(`payment:${hash}`))); + // Older history was moved to the archive, and funds rotated on 2026-08-25 + // keep their archived history under the pre-rotation id + // (fund:rotatedFrom:<new> -> old, backfilled from fund:rotated:*). + const oldId = fid !== id ? id : await g(`fund:rotatedFrom:${fid}`); + const lists = await Promise.all([ + db.lRange(`fund:${fid}:payments`, 0, -1), + archive.lRange(`fund:${fid}:payments`, 0, -1), + ...(oldId + ? [ + db.lRange(`fund:${oldId}:payments`, 0, -1), + archive.lRange(`fund:${oldId}:payments`, 0, -1), + ] + : []), + ]); + let payments: any[] = [...new Set(lists.flatMap((l) => l || []))]; + payments = await Promise.all(payments.map((pid) => gf(`payment:${pid}`))); + + payments = payments + .filter((p) => p) + .sort((a, b) => b.created - a.created); await Promise.all( payments.map(async (p: any) => (p.user = await getUser(p.uid, fields))), ); - payments = payments.filter((p) => p); - const authorization = await g(`authorization:${fid}`); res.send({ amount, |
