Styles propagating - testing in prod now

This commit is contained in:
Ian Philips 2022-09-23 10:47:44 -04:00
parent 1408f6c44e
commit 7d138d1ee9
5 changed files with 25 additions and 14 deletions

View File

@ -261,7 +261,7 @@
<p style='display: inline'>
{{investment_value}}
<!-- M$10,000-->
<p style='font-size:14px;display: inline; padding: 2px; border-radius: 5px; background-color: rgba(160,0,0,0.2);'>
<p style='{{investment_change_style}}'>
{{investment_change}}
<!-- +17%-->
</p>
@ -317,7 +317,7 @@
<p style='font-size: 24px;display: inline'>
{{question1Prob}}
<!-- 99.9%-->
<p style='font-size:14px;display: inline; padding: 2px; border-radius: 5px; background-color: rgba(160,0,0,0.2);'>
<p style='{{question1ChangeStyle}}'>
{{question1Change}}
<!-- +17%-->
</p>
@ -335,7 +335,7 @@
<p style='font-size: 24px;display: inline'>
{{question2Prob}}
<!-- 99.9%-->
<p style='font-size:14px;display: inline; padding: 2px; border-radius: 5px; background-color: rgba(160,0,0,0.2);'>
<p style='{{question2ChangeStyle}}'>
{{question2Change}}
<!-- +17%-->
</p>
@ -353,7 +353,7 @@
<p style='font-size: 24px;display: inline'>
{{question3Prob}}
<!-- 99.9%-->
<p style='font-size:14px;display: inline; padding: 2px; border-radius: 5px; background-color: rgba(160,0,0,0.2);'>
<p style='{{question3ChangeStyle}}'>
{{question3Change}}
<!-- +17%-->
</p>
@ -371,7 +371,7 @@
<p style='font-size: 24px;display: inline'>
{{question4Prob}}
<!-- 99.9%-->
<p style='font-size:14px;display: inline; padding: 2px; border-radius: 5px; background-color: rgba(160,0,0,0.2);'>
<p style='{{question4ChangeStyle}}'>
{{question4Change}}
<!-- +17%-->
</p>

View File

@ -23,7 +23,7 @@ import {
import {
PerContractInvestmentsData,
OverallPerformanceData,
} from './weekly-profit-loss-emails'
} from 'functions/src/weekly-portfolio-emails'
export const sendMarketResolutionEmail = async (
reason: notification_reason_types,
@ -642,6 +642,7 @@ export const sendWeeklyPortfolioUpdateEmail = async (
templateData[`question${i + 1}Url`] = investment.questionUrl
templateData[`question${i + 1}Prob`] = investment.questionProb
templateData[`question${i + 1}Change`] = investment.questionChange
templateData[`question${i + 1}ChangeStyle`] = investment.questionChangeStyle
})
await sendTemplateEmail(

View File

@ -30,7 +30,7 @@ export * from './reset-betting-streaks'
export * from './reset-weekly-emails-flag'
export * from './on-update-contract-follow'
export * from './on-update-like'
export * from './weekly-profit-loss-emails'
export * from './weekly-portfolio-emails'
// v2
export * from './health'

View File

@ -1,5 +1,5 @@
import { APIError, newEndpoint } from './api'
import { sendPortfolioUpdateEmailsToAllUsers } from './weekly-profit-loss-emails'
import { sendPortfolioUpdateEmailsToAllUsers } from './weekly-portfolio-emails'
import { isProd } from './utils'
export const testscheduledfunction = newEndpoint(

View File

@ -3,7 +3,6 @@ import * as admin from 'firebase-admin'
import { Contract, CPMMContract } from '../../common/contract'
import {
getAllPrivateUsers,
getPrivateUser,
getUser,
getValue,
@ -36,7 +35,8 @@ const firestore = admin.firestore()
export async function sendPortfolioUpdateEmailsToAllUsers() {
const privateUsers = isProd()
? await getAllPrivateUsers()
? // ? await getAllPrivateUsers()
filterDefined([await getPrivateUser('AJwLWoo3xue32XIiAVrL5SyR1WB2')])
: filterDefined([await getPrivateUser('6hHpzvRG0pMq8PNJs7RZj2qlZGn2')])
// get all users that haven't unsubscribed from weekly emails
const privateUsersToSendEmailsTo = privateUsers
@ -152,15 +152,15 @@ export async function sendPortfolioUpdateEmailsToAllUsers() {
log('No portfolio metrics a week ago for user', privateUser.id)
return
}
const valueChange =
mostRecentPortfolioMetrics.investmentValue -
portfolioMetricsAWeekAgo.investmentValue
// get the difference
const performanceData = {
investment_value: formatMoney(
mostRecentPortfolioMetrics.investmentValue
),
investment_change: formatMoney(
portfolioMetricsAWeekAgo.investmentValue -
mostRecentPortfolioMetrics.investmentValue
),
investment_change: formatMoney(valueChange),
current_balance: formatMoney(user.balance),
markets_created:
usersToContractsCreated[privateUser.id].length.toString(),
@ -174,6 +174,9 @@ export async function sendPortfolioUpdateEmailsToAllUsers() {
unique_bettors: usersToTxnsReceived[privateUser.id]
.filter((txn) => txn.category === 'UNIQUE_BETTOR_BONUS')
.length.toString(),
investment_change_style: `font-size:14px;display: inline; padding: 2px; border-radius: 5px; background-color: ${
valueChange > 0 ? 'rgba(0,160,0,0.2)' : 'rgba(160,0,0,0.2)'
};`,
// More options: bonuses, tips given,
} as OverallPerformanceData
type investmentDiff = {
@ -219,6 +222,11 @@ export async function sendPortfolioUpdateEmailsToAllUsers() {
Math.round(
(currentMarketProbability - marketProbabilityAWeekAgo) * 100
) + '%',
questionChangeStyle: `font-size:14px;display: inline; padding: 2px; border-radius: 5px; background-color: ${
currentMarketProbability > marketProbabilityAWeekAgo
? 'rgba(0,160,0,0.2)'
: 'rgba(160,0,0,0.2)'
};`,
}
})
),
@ -265,8 +273,10 @@ export type PerContractInvestmentsData = {
questionUrl: string
questionProb: string
questionChange: string
questionChangeStyle: string
}
export type OverallPerformanceData = {
investment_change_style: string
investment_value: string
investment_change: string
current_balance: string