Skip to content

fix(gamification): on-read streak recalculation + AI summary cap 300 chars - #203

Merged
thomasluizon merged 1 commit into
mainfrom
fix/qa-batch-2026-06-12
Jun 12, 2026
Merged

fix(gamification): on-read streak recalculation + AI summary cap 300 chars#203
thomasluizon merged 1 commit into
mainfrom
fix/qa-batch-2026-06-12

Conversation

@thomasluizon

@thomasluizon thomasluizon commented Jun 12, 2026

Copy link
Copy Markdown
Owner

What

QA batch (backend half) - paired frontend PR: thomasluizon/orbit-ui-mobile#168.

Streak: recalculate on read

GetStreakInfoQuery returned the stored Users.CurrentStreak / LastActiveDate columns 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 calls RecalculateAsync (with awardFreezeIfEligible: 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, CapToSentence truncation), 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 shared AI_SUMMARY_MAX_CHARS.

Tests

  • GetStreakInfoQueryHandlerTests: new case asserting recalculated values are returned and persisted; existing cases updated for the new dependencies.
  • Full suite: 3156 passed, 0 failed.

🤖 Generated with Claude Code

…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>

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@sonarqubecloud

Copy link
Copy Markdown

@thomasluizon
thomasluizon merged commit 74fb174 into main Jun 12, 2026
6 checks passed
@thomasluizon
thomasluizon deleted the fix/qa-batch-2026-06-12 branch June 12, 2026 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant