diff --git a/api/QuestionsApi/Services/CreditStore.cs b/api/QuestionsApi/Services/CreditStore.cs index 5914ed0..5e6ee86 100644 --- a/api/QuestionsApi/Services/CreditStore.cs +++ b/api/QuestionsApi/Services/CreditStore.cs @@ -66,8 +66,14 @@ public sealed class CreditStore value => value.UserId == userId, Builders.Update .SetOnInsert(value => value.UserId, userId) + .SetOnInsert(value => value.Credits, 0) + .SetOnInsert(value => value.RecentEarnings, []) .SetOnInsert(value => value.UpdatedUtc, now), new UpdateOptions { IsUpsert = true }); + await _accounts.UpdateOneAsync( + Builders.Filter.Eq(value => value.UserId, userId) & + Builders.Filter.Exists(nameof(UserCreditAccount.RecentEarnings), false), + Builders.Update.Set(value => value.RecentEarnings, [])); var cutoff = now - CreditEconomy.EarningWindow; await _accounts.UpdateOneAsync( value => value.UserId == userId,