Skip to content

feat(ai): persist hint usage and difficulty analytics (BA-081) - #735

Merged
MaryammAli merged 1 commit into
BlockDash-Studios:mainfrom
BobbyRichie2:feat/649-hint-usage-analytics
Aug 28, 2026
Merged

feat(ai): persist hint usage and difficulty analytics (BA-081)#735
MaryammAli merged 1 commit into
BlockDash-Studios:mainfrom
BobbyRichie2:feat/649-hint-usage-analytics

Conversation

@BobbyRichie2

Copy link
Copy Markdown
Contributor

Closes #649

Description

In-memory hint counts disappear on restart and cannot support difficulty calibration across instances. This change makes hint usage durable, user-scoped, deduplicated per user, and queryable for analytics.

Changes

  • Track hint usage keyed by userId:hintId (deduplicated: repeated requests from the same user increment usedCount on one record)
  • Persist records to Redis under hint:usage:{userId}:{hintId} and unique-user sets under hint:users:{hintId}
  • getHintUsageAnalytics() aggregates totalUses, uniqueUsers, usesByHint, usesByDifficulty, and per-record details
  • Mirror Redis state into a fresh service instance so counts survive restarts / replicas
  • Expose GET /ai/hints/analytics
  • Unit tests for deduplication, user-scoping, difficulty distribution, and restart durability

Verification

  • npm test src/ai/ai.service.spec.ts passes (10/10)

…Dash-Studios#649)

- Track hint usage durably, keyed by userId:hintId (deduplicated per user)
- Persist records to Redis under hint:usage:... and unique-user sets under hint:users:...
- Add getHintUsageAnalytics() aggregating totalUses, uniqueUsers, usesByHint, usesByDifficulty
- Mirror Redis state into a fresh service instance so counts survive restarts
- Expose GET /ai/hints/analytics endpoint
- Add unit tests for dedup, user-scoping, difficulty distribution, and restart durability
@drips-wave

drips-wave Bot commented Aug 28, 2026

Copy link
Copy Markdown

@BobbyRichie2 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@MaryammAli MaryammAli left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@MaryammAli MaryammAli left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@MaryammAli
MaryammAli merged commit 540955c into BlockDash-Studios:main Aug 28, 2026
1 of 2 checks passed
@BobbyRichie2

Copy link
Copy Markdown
Contributor Author

This PR was re-created as #745 to correct commit authorship attribution (commits were initially authored with the wrong git identity). The replacement PR is identical in content.

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.

BA-081 — Persist hint usage and difficulty analytics

3 participants