Only backfill unfilled users' badges

This commit is contained in:
Ian Philips 2022-10-10 14:34:06 -06:00
parent f26ba1c4a2
commit 867cdf2496

View File

@ -20,17 +20,18 @@ async function main() {
// const users = filterDefined([await getUser('AJwLWoo3xue32XIiAVrL5SyR1WB2')]) // prod ian // const users = filterDefined([await getUser('AJwLWoo3xue32XIiAVrL5SyR1WB2')]) // prod ian
await Promise.all( await Promise.all(
users.map(async (user) => { users.map(async (user) => {
// console.log('Added achievements to user', user.id)
if (!user.id) return if (!user.id) return
// Only backfill users without achievements
if (user.achievements === undefined) { if (user.achievements === undefined) {
await firestore.collection('users').doc(user.id).update({ await firestore.collection('users').doc(user.id).update({
achievements: {}, achievements: {},
}) })
user.achievements = {} user.achievements = {}
user.achievements = await awardMarketCreatorBadges(user)
user.achievements = await awardBettingStreakBadges(user)
console.log('Added achievements to user', user.id)
// going to ignore backfilling the proven correct badges for now
} }
user.achievements = await awardMarketCreatorBadges(user)
user.achievements = await awardBettingStreakBadges(user)
// going to ignore backfilling the proven correct badges for now
}) })
) )
} }