refactor(audit-log): cache fetched user in AuditLogManager#216
Conversation
Introduce a #user field to memoize the result of container.client.users.fetch, avoiding repeated network calls within the same AuditLogManager instance. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
📝 WalkthroughSummary by CodeRabbit
Walkthrough
ChangesAuditLogManager actor fetch hoisting
Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…nchronous #buildCommandExecuteEmbed and #buildSettingsChangeEmbed are now sync methods that receive a pre-fetched User, keeping the makeMessage factory synchronous as the GuildMessageLog event system expects. Also restores the try/catch fallback in #fetchUser that was lost in the previous commit, and updates tests to reflect the description-based embed format introduced in PR #215. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/lib/database/settings/structures/AuditLogManager.test.ts (1)
7-7: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse configured path aliases instead of deep relative import
Line 7 should use the configured alias form (for example via
#root/*) rather than../../../../...to stay consistent with the TS import standard in this repo.
As per coding guidelines, "Use path aliases:#lib/,#utils/,#generated/prisma,#root/*,#languages".🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/lib/database/settings/structures/AuditLogManager.test.ts` at line 7, The test import in AuditLogManager.test.ts is using a deep relative path instead of the repo’s configured alias style. Update the createUser import to use the appropriate path alias (for example `#root/`*) rather than traversing with ../../../../, and keep the import consistent with the alias conventions used elsewhere in the test suite.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@tests/lib/database/settings/structures/AuditLogManager.test.ts`:
- Line 7: The test import in AuditLogManager.test.ts is using a deep relative
path instead of the repo’s configured alias style. Update the createUser import
to use the appropriate path alias (for example `#root/`*) rather than traversing
with ../../../../, and keep the import consistent with the alias conventions
used elsewhere in the test suite.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: fa3aba36-2971-4fe9-83ac-7c3b44e18646
📒 Files selected for processing (2)
src/lib/database/settings/structures/AuditLogManager.tstests/lib/database/settings/structures/AuditLogManager.test.ts
Summary
#userprivate field toAuditLogManagerto memoize the result ofcontainer.client.users.fetch#fetchUserwith a single??=assignment for lazy cachingType of Change
Test Plan
#fetchUseris not called more than once perAuditLogManagerinstance when the same user triggers multiple log entries