From 89dbe3e31a21b550da9f96304cb104aaf8413429 Mon Sep 17 00:00:00 2001 From: hz Date: Tue, 28 Jul 2026 20:52:20 -0500 Subject: [PATCH] Initialize credit earning ledger arrays --- api/QuestionsApi/Services/CreditStore.cs | 6 ++++++ 1 file changed, 6 insertions(+) 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,