Show investment in market resolve email
This commit is contained in:
parent
64223e5ff1
commit
db541cb63b
|
@ -437,6 +437,28 @@
|
|||
margin: 0;
|
||||
"
|
||||
/>
|
||||
Your investment was
|
||||
<span style="font-weight: bold"
|
||||
>M$ {{investment}}</span
|
||||
>.
|
||||
<br
|
||||
style="
|
||||
font-family: 'Helvetica Neue', Helvetica,
|
||||
Arial, sans-serif;
|
||||
box-sizing: border-box;
|
||||
font-size: 16px;
|
||||
margin: 0;
|
||||
"
|
||||
/>
|
||||
<br
|
||||
style="
|
||||
font-family: 'Helvetica Neue', Helvetica,
|
||||
Arial, sans-serif;
|
||||
box-sizing: border-box;
|
||||
font-size: 16px;
|
||||
margin: 0;
|
||||
"
|
||||
/>
|
||||
Your payout is
|
||||
<span style="font-weight: bold"
|
||||
>M$ {{payout}}</span
|
||||
|
|
|
@ -16,6 +16,7 @@ type market_resolved_template = {
|
|||
creatorName: string
|
||||
question: string
|
||||
outcome: string
|
||||
investment: string
|
||||
payout: string
|
||||
url: string
|
||||
}
|
||||
|
@ -39,6 +40,7 @@ const toDisplayResolution = (
|
|||
|
||||
export const sendMarketResolutionEmail = async (
|
||||
userId: string,
|
||||
investment: number,
|
||||
payout: number,
|
||||
creator: User,
|
||||
contract: Contract,
|
||||
|
@ -69,6 +71,7 @@ export const sendMarketResolutionEmail = async (
|
|||
creatorName: creator.name,
|
||||
question: contract.question,
|
||||
outcome,
|
||||
investment: `${Math.round(investment)}`,
|
||||
payout: `${Math.round(payout)}`,
|
||||
url: `https://manifold.markets/${creator.username}/${contract.slug}`,
|
||||
}
|
||||
|
|
|
@ -134,14 +134,24 @@ const sendResolutionEmails = async (
|
|||
_.uniq(openBets.map(({ userId }) => userId)),
|
||||
Object.keys(userPayouts)
|
||||
)
|
||||
const investedByUser = _.mapValues(
|
||||
_.groupBy(openBets, (bet) => bet.userId),
|
||||
(bets) => _.sumBy(bets, (bet) => bet.amount)
|
||||
)
|
||||
const emailPayouts = [
|
||||
...Object.entries(userPayouts),
|
||||
...nonWinners.map((userId) => [userId, 0] as const),
|
||||
]
|
||||
].map(([userId, payout]) => ({
|
||||
userId,
|
||||
investment: investedByUser[userId],
|
||||
payout,
|
||||
}))
|
||||
|
||||
await Promise.all(
|
||||
emailPayouts.map(([userId, payout]) =>
|
||||
emailPayouts.map(({ userId, investment, payout }) =>
|
||||
sendMarketResolutionEmail(
|
||||
userId,
|
||||
investment,
|
||||
payout,
|
||||
creator,
|
||||
contract,
|
||||
|
|
Loading…
Reference in New Issue
Block a user