[WordService] Refactor RestoreFrontierWords#4147
[WordService] Refactor RestoreFrontierWords#4147imnasnainaec wants to merge 4 commits intomasterfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 📝 WalkthroughWalkthroughAdds a batch word retrieval method to the repository and mock, and refactors RestoreFrontierWords to deduplicate inputs, perform batched frontier and repository checks, reject deleted or missing words, and batch-add valid words to the Frontier. Changes
Sequence Diagram(s)sequenceDiagram
participant Client as Client
participant Service as WordService
participant Repo as WordRepository
participant Frontier as FrontierStore
Client->>Service: RestoreFrontierWords(projectId, wordIds)
Note right of Service: deduplicate wordIds
Service->>Frontier: AreInFrontier(projectId, wordIds)
Frontier-->>Service: noneInFrontier / someInFrontier
alt someInFrontier
Service-->>Client: return false
else noneInFrontier
Service->>Repo: GetWords(projectId, wordIds)
Repo-->>Service: List<Word> (may be incomplete)
alt count mismatch or contains Deleted
Service-->>Client: return false
else valid words
Service->>Frontier: AddFrontier(projectId, words)
Frontier-->>Service: success
Service-->>Client: return true
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 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 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #4147 +/- ##
===========================================
+ Coverage 74.76% 86.03% +11.27%
===========================================
Files 302 56 -246
Lines 11068 4834 -6234
Branches 1389 600 -789
===========================================
- Hits 8275 4159 -4116
+ Misses 2390 528 -1862
+ Partials 403 147 -256
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@Backend/Services/WordService.cs`:
- Around line 101-122: The method processes wordIds and currently can call
_wordRepo.AddFrontier(words) with an empty list, which triggers
MongoDB/InsertManyAsync ArgumentException; add an explicit guard after
deduplication (wordIds = wordIds.Distinct().ToList()) or after fetching words to
return false / no-op when wordIds (or words) is empty so AddFrontier is never
invoked with an empty collection — update the logic around wordIds / words
checks in WordService (references: wordIds, _wordRepo.AreInFrontier,
_wordRepo.GetWords, _wordRepo.AddFrontier) to short-circuit when empty.
|
Replaced by #4161 |
A less important piece of #4146
This change is
Summary by CodeRabbit
New Features
Bug Fixes
Refactor