Reduce redundant DB writes for users and channel configs#6508
Conversation
PR checklist ✅All required conditions are satisfied:
🎉 Great job! This PR is ready for review. |
SDK Size Comparison 📏
|
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
WalkthroughTwo offline repository classes ( ChangesRepository insert deduplication
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |



Goal
Persisting a channel response fans out into redundant SQLite writes: the same user gets inserted once per reference in the payload, and the channel list rewrites each channel's config once per channel. A customer flagged the volume. This dedups before the DB write, with no behaviour change.
Closes AND-1247
Implementation
insertUsers: dedup users by id (Channel.users()lists the same user once per member/author/watcher/etc.).insertChannelConfigs: dedup configs by type (one row per type, not per channel).Both keep the last occurrence, matching the existing
INSERT OR REPLACEbehaviour.Testing
UserRepositoryTestsandChannelConfigRepositoryTestcovering the dedup.Summary by CodeRabbit