From 867cdf249638e05562ca2fcdd3165433247b7693 Mon Sep 17 00:00:00 2001 From: Ian Philips Date: Mon, 10 Oct 2022 14:34:06 -0600 Subject: [PATCH] Only backfill unfilled users' badges --- functions/src/scripts/backfill-badges.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/functions/src/scripts/backfill-badges.ts b/functions/src/scripts/backfill-badges.ts index 648467cf..145f064c 100644 --- a/functions/src/scripts/backfill-badges.ts +++ b/functions/src/scripts/backfill-badges.ts @@ -20,17 +20,18 @@ async function main() { // const users = filterDefined([await getUser('AJwLWoo3xue32XIiAVrL5SyR1WB2')]) // prod ian await Promise.all( users.map(async (user) => { - // console.log('Added achievements to user', user.id) if (!user.id) return + // Only backfill users without achievements if (user.achievements === undefined) { await firestore.collection('users').doc(user.id).update({ 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 }) ) }