mirror of
https://github.com/tiennm99/miti99bot.git
synced 2026-04-17 15:20:58 +00:00
feat: add meta.createdAt to portfolio for future analytics
This commit is contained in:
@@ -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 },
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user