Skip to content

Conversation

@myieye
Copy link
Contributor

@myieye myieye commented Oct 21, 2025

I exposed this for a test:
https://github.com/sillsdev/languageforge-lexbox/blob/19cc6898cdaab426d9ac11947706bbff4ce9bc2a/backend/FwLite/LcmCrdt.Tests/Data/MigrationTests.cs#L128

Summary by CodeRabbit

  • New Features
    • Added capability to retrieve the latest snapshots asynchronously, enabling more efficient access to recent data within the application.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 21, 2025

Walkthrough

A new public async method GetLatestSnapshots is added to the DataModel class, returning an IAsyncEnumerable<ObjectSnapshot>. The method creates a repository instance, iterates over current snapshots, and yields each result asynchronously.

Changes

Cohort / File(s) Summary
New async snapshot enumeration method
src/SIL.Harmony/DataModel.cs
Added public method GetLatestSnapshots() returning IAsyncEnumerable<ObjectSnapshot> that retrieves and yields current snapshots from a repository asynchronously

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

🐰 A snapshot method hops into view,
Async and graceful, through and through!
CurrentSnapshots now has a friend,
Yielding data without end. ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The PR title "Expose GetLatestSnapshots on DataModel" directly and clearly describes the main change in the pull request. The title specifically names the method being exposed (GetLatestSnapshots) and the class it's being added to (DataModel), which aligns perfectly with the actual code change of adding a new public method to the DataModel class. The title is concise, specific, and would enable a developer scanning the repository history to immediately understand the primary purpose of this change.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch expose-get-latest-snapshots-on-data-model

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.

Copy link
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.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/SIL.Harmony/DataModel.cs (1)

254-261: Consider adding .AsNoTracking() for performance, and evaluate whether this should be public.

Since this method is exposed solely for testing (per PR description), consider making it internal and using [assembly: InternalsVisibleTo("TestAssemblyName")] to avoid polluting the public API surface. Additionally, the method should likely use .AsNoTracking() to prevent EF from tracking potentially large numbers of entities, which improves performance and reduces memory overhead. Other read-only query methods in this class use this pattern (e.g., line 221).

Apply this diff to add .AsNoTracking():

 public async IAsyncEnumerable<ObjectSnapshot> GetLatestSnapshots()
 {
     await using var repo = await _crdtRepositoryFactory.CreateRepository();
-    await foreach (var snapshot in repo.CurrentSnapshots().AsAsyncEnumerable())
+    await foreach (var snapshot in repo.CurrentSnapshots().AsNoTracking().AsAsyncEnumerable())
     {
         yield return snapshot;
     }
 }

Optionally, consider adding an includeDeleted parameter for consistency with GetProjectSnapshot (line 291) if your test scenarios require it.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a9600a0 and 4c7dc0a.

📒 Files selected for processing (1)
  • src/SIL.Harmony/DataModel.cs (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/SIL.Harmony/DataModel.cs (3)
src/SIL.Harmony/Db/CrdtRepository.cs (3)
  • IAsyncEnumerable (192-208)
  • IAsyncEnumerable (403-406)
  • IAsyncEnumerable (407-410)
src/SIL.Harmony/SnapshotWorker.cs (2)
  • IAsyncEnumerable (166-169)
  • IAsyncEnumerable (171-197)
src/SIL.Harmony/Db/ObjectSnapshot.cs (2)
  • ObjectSnapshot (32-80)
  • ObjectSnapshot (34-48)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: build
  • GitHub Check: build
  • GitHub Check: Analyze (csharp)

@myieye myieye enabled auto-merge (squash) October 28, 2025 15:42
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.

2 participants