Skip to content

[WordService] Refactor RestoreFrontierWords#4161

Merged
imnasnainaec merged 5 commits intomasterfrom
word-service-restore-frontier-words
Feb 19, 2026
Merged

[WordService] Refactor RestoreFrontierWords#4161
imnasnainaec merged 5 commits intomasterfrom
word-service-restore-frontier-words

Conversation

@imnasnainaec
Copy link
Copy Markdown
Collaborator

@imnasnainaec imnasnainaec commented Feb 17, 2026

This change is Reviewable

Summary by CodeRabbit

  • New Features

    • Batch retrieval of multiple words for faster, more efficient fetching.
    • Single-word fetches now respect project scoping.
  • Bug Fixes

    • Improved word restoration: handles empty input, deduplicates IDs, validates existence and non-deleted status in batch, and performs all-or-nothing restores to prevent partial or invalid restorations.

@imnasnainaec imnasnainaec self-assigned this Feb 17, 2026
@imnasnainaec imnasnainaec added the 🟨Medium Medium-priority PR label Feb 17, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 17, 2026

No actionable comments were generated in the recent review. 🎉


📝 Walkthrough

Walkthrough

Added a bulk GetWords method to the repository interface, implementation, and mock; and refactored RestoreFrontierWords to deduplicate IDs, perform batch validation/fetch via the new GetWords, and add all valid words to the Frontier in one all‑or‑nothing operation.

Changes

Cohort / File(s) Summary
Repository Interface & Impl
Backend/Interfaces/IWordRepository.cs, Backend/Repositories/WordRepository.cs
Added GetWords(string projectId, List<string> wordIds) to the interface and implementation; implementation opens an OTEL activity and returns project-scoped results as List<Word>.
Repository Mock
Backend.Tests/Mocks/WordRepositoryMock.cs
Added GetWords(string projectId, List<string> wordIds) to the mock; updated GetWord(string projectId, string wordId) to filter by both ProjectId and Id and return cloned Word instances.
Service Logic
Backend/Services/WordService.cs
Refactored RestoreFrontierWords to short-circuit on empty input, deduplicate IDs, batch-check frontier membership, fetch words via GetWords, validate existence/non-deleted in bulk, and perform a single batch addition to the Frontier (all-or-nothing).

Sequence Diagram(s)

sequenceDiagram
    participant Client as Client
    participant Service as WordService
    participant Repo as WordRepository
    participant Store as DataStore

    Client->>Service: RestoreFrontierWords(projectId, wordIds)
    Service->>Service: Deduplicate IDs & early return if empty
    Service->>Repo: GetWords(projectId, dedupedWordIds)
    Repo->>Store: Query words filtered by project + ids
    Store-->>Repo: Return matching Word records
    Repo-->>Service: Return List<Word>
    Service->>Service: Validate existence, non-deleted, not-in-frontier
    alt All valid
        Service->>Store: Add words to Frontier (batch)
        Store-->>Service: Acknowledge
        Service-->>Client: Success (true)
    else Any invalid
        Service-->>Client: Failure (false)
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Suggested labels

refactor

Suggested reviewers

  • jasonleenaylor

Poem

🐰 I hopped through lists and gathered each one,
Dedupe and fetch — a tidy batch is done.
No deleted leaves be carried on the run,
The Frontier fills in a single sunlit hop. 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 43.75% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title '[WordService] Refactor RestoreFrontierWords' clearly and specifically identifies the main change: refactoring the RestoreFrontierWords method in WordService with supporting changes to interfaces and implementations.

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

✨ 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 word-service-restore-frontier-words

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.

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 17, 2026

Codecov Report

❌ Patch coverage is 71.42857% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.08%. Comparing base (e85c895) to head (97711ee).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
Backend/Services/WordService.cs 71.42% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #4161       +/-   ##
===========================================
+ Coverage   74.79%   86.08%   +11.28%     
===========================================
  Files         302       56      -246     
  Lines       11081     4842     -6239     
  Branches     1393      603      -790     
===========================================
- Hits         8288     4168     -4120     
+ Misses       2390      528     -1862     
+ Partials      403      146      -257     
Flag Coverage Δ
backend 86.08% <71.42%> (-0.09%) ⬇️
frontend ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@imnasnainaec

This comment was marked as resolved.

@coderabbitai

This comment was marked as outdated.

coderabbitai[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

Copy link
Copy Markdown
Contributor

@jasonleenaylor jasonleenaylor left a comment

Choose a reason for hiding this comment

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

@jasonleenaylor reviewed 4 files and all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on imnasnainaec).

@imnasnainaec imnasnainaec merged commit 25a03f8 into master Feb 19, 2026
18 of 19 checks passed
@imnasnainaec imnasnainaec deleted the word-service-restore-frontier-words branch February 19, 2026 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants