feat: add meta.createdAt to portfolio for future analytics

This commit is contained in:
2026-04-14 18:00:42 +07:00
parent e265cfa9b5
commit fb8c7518f7

View File

@@ -18,7 +18,7 @@
/** @returns {Portfolio} */ /** @returns {Portfolio} */
export function emptyPortfolio() { export function emptyPortfolio() {
return { currency: { VND: 0 }, assets: {}, meta: { invested: 0 } }; return { currency: { VND: 0 }, assets: {}, meta: { invested: 0, createdAt: Date.now() } };
} }
/** /**
@@ -40,11 +40,12 @@ export async function getPortfolio(db, userId) {
// migrate: totalvnd → meta.invested // migrate: totalvnd → meta.invested
const invested = raw.meta?.invested ?? raw.totalvnd ?? 0; const invested = raw.meta?.invested ?? raw.totalvnd ?? 0;
const createdAt = raw.meta?.createdAt ?? Date.now();
return { return {
currency: { VND: 0, ...raw.currency }, currency: { VND: 0, ...raw.currency },
assets, assets,
meta: { invested }, meta: { invested, createdAt },
}; };
} }