Working tree is now the canonical repo. Off-chain play-money + trustless on-chain (FPMM AMM + CLOB via UMA settlement), AI market factory, creator/social/distribution, mobile shell + push, one-command demo + deploy-kit. Secrets excluded (see ENV-AND-KEYS.md). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
35 lines
1022 B
TypeScript
35 lines
1022 B
TypeScript
import { writeFileSync } from 'fs'
|
|
import { initAdmin } from 'shared/init-admin'
|
|
initAdmin()
|
|
import { User } from 'common/user'
|
|
import { getPrivateUser } from 'shared/utils'
|
|
import * as admin from 'firebase-admin'
|
|
import { DAY_MS } from 'common/util/time'
|
|
|
|
async function main() {
|
|
const firestore = admin.firestore()
|
|
// Last run on 4/18/2023
|
|
const usersSnap = await firestore
|
|
.collection('users')
|
|
.where('createdTime', '>=', Date.now() - 12 * DAY_MS)
|
|
.get()
|
|
const users = usersSnap.docs.map((doc) => doc.data() as User)
|
|
|
|
console.log('Loaded', users.length, 'users')
|
|
const csv = await Promise.all(
|
|
users.map(async (user: User) => {
|
|
const privateUser = await getPrivateUser(user.id)
|
|
if (!privateUser || !privateUser.email) return ''
|
|
return `${privateUser.email},\n`
|
|
})
|
|
)
|
|
try {
|
|
csv.unshift('email\n')
|
|
writeFileSync('new-user-emails.csv', csv.join(''))
|
|
} catch (err) {
|
|
console.error(err)
|
|
}
|
|
}
|
|
|
|
if (require.main === module) main().then(() => process.exit())
|