fix(gamification): on-read streak recalculation + AI summary cap 300 chars - #203
Conversation
…to 300 chars - GetStreakInfoQuery now recalculates the user streak (without awarding freezes) and persists it before responding, honoring the on-read contract the auto-freeze service documents - AiSummaryService: MaxSummaryChars 140 -> 300, maxOutputTokens 120 -> 180, prompt asks for two short sentences instead of one Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Two clean, self-contained fixes. The on-read streak recalculation correctly sits after the Pro gate, uses awardFreezeIfEligible: false to stay passive, and guards the SaveChanges on a null return — matching how every other command uses RecalculateAsync. The AI summary bump updates all three limits (const, maxOutputTokens, prompt) consistently. Test coverage is solid: the new Handle_RecalculatesStreakOnRead_AndReturnsFreshValues case asserts the fresh values and the SaveChanges call, while the existing test covers the null-recalc fallback path (NSubstitute default). Nothing to block here.
|



What
QA batch (backend half) - paired frontend PR: thomasluizon/orbit-ui-mobile#168.
Streak: recalculate on read
GetStreakInfoQueryreturned the storedUsers.CurrentStreak/LastActiveDatecolumns verbatim, which only refresh when a log/delete command happens to run. The auto-freeze service explicitly documents that "the next on-read RecalculateAsync keeps CurrentStreak intact" - but no read path ever recalculated. The handler now callsRecalculateAsync(withawardFreezeIfEligible: false), persists the corrected state, and builds the response from the fresh values, so the streak page can never serve stale numbers.AI summary: 140 -> 300 chars
The Astra daily summary was capped at 140 chars at three layers (prompt instruction,
maxOutputTokens: 120,CapToSentencetruncation), too short to say anything meaningful. Now:MaxSummaryChars = 300,maxOutputTokens: 180, prompt asks for two short sentences (three when warranted). Clients mirror the new threshold via sharedAI_SUMMARY_MAX_CHARS.Tests
GetStreakInfoQueryHandlerTests: new case asserting recalculated values are returned and persisted; existing cases updated for the new dependencies.🤖 Generated with Claude Code