Skip to content

chore(persistence): Remove unused DAO methods#2695

Open
VelikovPetar wants to merge 3 commits into
masterfrom
feature/FLU-501_cleanup_unused_daos
Open

chore(persistence): Remove unused DAO methods#2695
VelikovPetar wants to merge 3 commits into
masterfrom
feature/FLU-501_cleanup_unused_daos

Conversation

@VelikovPetar
Copy link
Copy Markdown
Contributor

@VelikovPetar VelikovPetar commented May 28, 2026

Submit a pull request

Linear: FLU-501

CLA

  • I have signed the Stream CLA (required).
  • The code changes follow best practices
  • Code changes are tested (add some information if not applicable)

Description of the pull request

  • Removes all unused DAO methods

Summary by CodeRabbit

  • Refactor

    • Improved persistence performance via multi-channel batch (bulk) update operations for members, messages, reads, and pinned messages
    • Simplified persistence surface by consolidating single-channel calls into standardized bulk-update calls
    • Removed a few legacy query helpers to streamline data access
  • Tests

    • Updated tests to use the new bulk-update flows and validate behavior accordingly

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 28, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e3990bd5-6ede-486d-b9fb-71b2ac111c9e

📥 Commits

Reviewing files that changed from the base of the PR and between e5282c4 and 84d6af3.

📒 Files selected for processing (1)
  • packages/stream_chat_persistence/test/src/dao/user_dao_test.dart
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/stream_chat_persistence/test/src/dao/user_dao_test.dart

📝 Walkthrough

Walkthrough

Consolidates persistence DAOs to bulk map-based update APIs, removes several single-channel wrappers and unused list/query methods, and updates tests to seed and verify data using the new bulkUpdate* map payloads.

Changes

DAO API and Test Consolidation

Layer / File(s) Summary
Core bulk operation consolidation
packages/stream_chat_persistence/lib/src/dao/member_dao.dart, packages/stream_chat_persistence/lib/src/dao/message_dao.dart, packages/stream_chat_persistence/lib/src/dao/read_dao.dart
Member, Message, and Read DAOs remove single-channel update* wrappers and expose only bulkUpdate* methods that accept Map<String, List<T>?> payloads for batched upserts.
Auxiliary DAO cleanup and query removals
packages/stream_chat_persistence/lib/src/dao/pinned_message_dao.dart, packages/stream_chat_persistence/lib/src/dao/poll_dao.dart, packages/stream_chat_persistence/lib/src/dao/user_dao.dart
PinnedMessage DAO removes getThreadMessages and getThreadMessagesByParentId and its single-channel updateMessages; Poll DAO removes getPolls(); User DAO removes getUsers().
Test updates for bulk operation APIs
packages/stream_chat_persistence/test/src/dao/*
Member, Message, Read, Channel, Draft Message, Pinned Message, Reaction, and related tests updated to seed and assert via bulkUpdate* map payloads ({ cid: [entities...] }) instead of single-channel update* calls.
Test refactoring for removed query methods
packages/stream_chat_persistence/test/src/dao/poll_dao_test.dart, packages/stream_chat_persistence/test/src/dao/user_dao_test.dart
Poll tests now verify poll state using getPollById(); User tests read persisted users via a new _readPersistedUsers() helper that queries database.users and maps rows to User.

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • xsahil03x

"🐰 I hopped through DAOs to batch the load,
Map keys and lists now share the road.
Tests follow suit with a tidy map,
Old single calls tucked in my lap,
Tiny paws, big batched ode."

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'chore(persistence): Remove unused DAO methods' accurately summarizes the main change: removal of unused DAO methods across multiple files in the persistence layer.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/FLU-501_cleanup_unused_daos

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@VelikovPetar VelikovPetar marked this pull request as ready for review May 28, 2026 07:38
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/stream_chat_persistence/test/src/dao/user_dao_test.dart (1)

57-80: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Make the upsert assertion deterministic.

At Line 62 and Line 79, forcing online: false can hide an upsert regression when the seeded value is already false. Toggle from the original value so the update is always validated.

Suggested patch
-    final copyUser = insertedUsers.first.copyWith(online: false);
+    final toggledOnline = !insertedUsers.first.online;
+    final copyUser = insertedUsers.first.copyWith(online: toggledOnline);
@@
-    expect(fetchedUsers.firstWhere((it) => it.id == copyUser.id).online, false);
+    expect(
+      fetchedUsers.firstWhere((it) => it.id == copyUser.id).online,
+      toggledOnline,
+    );
🤖 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 `@packages/stream_chat_persistence/test/src/dao/user_dao_test.dart` around
lines 57 - 80, The test's upsert assertion can be non-deterministic because it
forces copyUser.online = false even if the seeded user was already false; change
the update to toggle the original user's online value so the update always
changes state: locate where you create copyUser using
insertedUsers.first.copyWith(...) and set online to the negation of the original
(e.g., !insertedUsers.first.online) before calling userDao.updateUsers([...]),
then keep the subsequent checks using _readPersistedUsers and expectations on
copyUser and newUser.
🤖 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.

Outside diff comments:
In `@packages/stream_chat_persistence/test/src/dao/user_dao_test.dart`:
- Around line 57-80: The test's upsert assertion can be non-deterministic
because it forces copyUser.online = false even if the seeded user was already
false; change the update to toggle the original user's online value so the
update always changes state: locate where you create copyUser using
insertedUsers.first.copyWith(...) and set online to the negation of the original
(e.g., !insertedUsers.first.online) before calling userDao.updateUsers([...]),
then keep the subsequent checks using _readPersistedUsers and expectations on
copyUser and newUser.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 312b532f-4787-4564-9846-6278f78ea79a

📥 Commits

Reviewing files that changed from the base of the PR and between d85ff66 and e5282c4.

📒 Files selected for processing (16)
  • packages/stream_chat_persistence/lib/src/dao/member_dao.dart
  • packages/stream_chat_persistence/lib/src/dao/message_dao.dart
  • packages/stream_chat_persistence/lib/src/dao/pinned_message_dao.dart
  • packages/stream_chat_persistence/lib/src/dao/poll_dao.dart
  • packages/stream_chat_persistence/lib/src/dao/read_dao.dart
  • packages/stream_chat_persistence/lib/src/dao/user_dao.dart
  • packages/stream_chat_persistence/test/src/dao/channel_dao_test.dart
  • packages/stream_chat_persistence/test/src/dao/draft_message_dao_test.dart
  • packages/stream_chat_persistence/test/src/dao/member_dao_test.dart
  • packages/stream_chat_persistence/test/src/dao/message_dao_test.dart
  • packages/stream_chat_persistence/test/src/dao/pinned_message_dao_test.dart
  • packages/stream_chat_persistence/test/src/dao/pinned_message_reaction_dao_test.dart
  • packages/stream_chat_persistence/test/src/dao/poll_dao_test.dart
  • packages/stream_chat_persistence/test/src/dao/reaction_dao_test.dart
  • packages/stream_chat_persistence/test/src/dao/read_dao_test.dart
  • packages/stream_chat_persistence/test/src/dao/user_dao_test.dart
💤 Files with no reviewable changes (5)
  • packages/stream_chat_persistence/lib/src/dao/member_dao.dart
  • packages/stream_chat_persistence/lib/src/dao/message_dao.dart
  • packages/stream_chat_persistence/lib/src/dao/user_dao.dart
  • packages/stream_chat_persistence/lib/src/dao/read_dao.dart
  • packages/stream_chat_persistence/lib/src/dao/poll_dao.dart

@codecov
Copy link
Copy Markdown

codecov Bot commented May 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.33%. Comparing base (d85ff66) to head (84d6af3).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2695      +/-   ##
==========================================
- Coverage   65.38%   65.33%   -0.06%     
==========================================
  Files         423      423              
  Lines       26664    26612      -52     
==========================================
- Hits        17435    17386      -49     
+ Misses       9229     9226       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

… test

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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