diff options
| -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, |
