Skip to content

Commit

Permalink
Don't send weekly emails on dev
Browse files Browse the repository at this point in the history
  • Loading branch information
IanPhilips committed May 29, 2024
1 parent d2822c1 commit d9879e0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
3 changes: 2 additions & 1 deletion backend/scheduler/src/jobs/streak-expiration-notice.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { getBettingStreakResetTimeBeforeNow, log } from 'shared/utils'
import { getBettingStreakResetTimeBeforeNow, isProd, log } from 'shared/utils'
import { createSupabaseDirectClient } from 'shared/supabase/init'
import { createBettingStreakExpiringNotification } from 'shared/create-notification'

export const sendStreakExpirationNotification = async () => {
if (!isProd()) return
const mostRecentResetTime = getBettingStreakResetTimeBeforeNow()
log('Most recent streak reset time', mostRecentResetTime)
const pg = createSupabaseDirectClient()
Expand Down
3 changes: 2 additions & 1 deletion backend/shared/src/onboarding-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
MARKET_VISIT_BONUS_TOTAL,
NEXT_DAY_BONUS,
} from 'common/economy'
import { getUser, getUsers, log } from 'shared/utils'
import { getUser, getUsers, isProd, log } from 'shared/utils'
import { SignupBonusTxn } from 'common/txn'
import {
MANIFOLD_AVATAR_URL,
Expand Down Expand Up @@ -37,6 +37,7 @@ D1 send mana bonus email
[deprecated] D2 send creator guide email
*/
export async function sendOnboardingNotificationsInternal() {
if (!isProd()) return
const { recentUserIds } = await getRecentNonLoverUserIds()

log(
Expand Down
3 changes: 2 additions & 1 deletion backend/shared/src/weekly-markets-emails.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { chunk } from 'lodash'

import { getPrivateUsersNotSent, getUser, log } from 'shared/utils'
import { getPrivateUsersNotSent, getUser, isProd, log } from 'shared/utils'
import { sendInterestingMarketsEmail } from 'shared/emails'
import { PrivateUser } from 'common/user'
import { getForYouSQL } from 'shared/supabase/search-contracts'
Expand All @@ -12,6 +12,7 @@ import { userIdsToAverageTopicConversionScores } from 'shared/topic-interests'
// Should scale until at least 1000 * 120 = 120k users signed up for emails (70k at writing)
const EMAILS_PER_BATCH = 1000
export async function sendWeeklyMarketsEmails() {
if (!isProd()) return
const pg = createSupabaseDirectClient()
const privateUsers = await getPrivateUsersNotSent(
'trending_markets',
Expand Down
17 changes: 7 additions & 10 deletions backend/shared/src/weekly-portfolio-emails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@ import {
CPMMContract,
CPMMMultiContract,
} from 'common/contract'
import {
getPrivateUsersNotSent,
getPrivateUser,
getUser,
isProd,
log,
} from 'shared/utils'
import { getPrivateUsersNotSent, getUser, isProd, log } from 'shared/utils'
import { filterDefined } from 'common/util/array'
import { DAY_MS } from 'common/util/time'
import { chunk, partition, sortBy, sum, uniq } from 'lodash'
Expand Down Expand Up @@ -37,10 +31,13 @@ const WEEKLY_MOVERS_TO_SEND = 6
// This should work until we have at least ~180k users (1000 * 180)
export async function sendPortfolioUpdateEmailsToAllUsers() {
const pg = createSupabaseDirectClient()
if (!isProd()) return

const privateUsers = isProd()
? await getPrivateUsersNotSent('profit_loss_updates', USERS_TO_EMAIL, pg)
: filterDefined([await getPrivateUser('6hHpzvRG0pMq8PNJs7RZj2qlZGn2')])
const privateUsers = await getPrivateUsersNotSent(
'profit_loss_updates',
USERS_TO_EMAIL,
pg
)

await pg.none(
`update private_users set weekly_portfolio_email_sent = true where id = any($1)`,
Expand Down

0 comments on commit d9879e0

Please sign in to comment.