Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 15, 2025

Implementation Complete

  • Create new database model ProjectSemanticDomainCount with projectId, domainId, and count fields
  • Create ISemanticDomainCountRepository interface with CRUD operations
  • Implement SemanticDomainCountRepository for database operations
  • Create ISemanticDomainCountService interface for business logic
  • Implement SemanticDomainCountService to handle count updates
  • Update WordService.Create() to increment counts after words are added
  • Update WordService.Update() to adjust counts after words are modified
  • Update WordService.Delete() and DeleteFrontierWord() to decrement counts after words are deleted
  • Update WordService.RestoreFrontierWords() to increment counts when words are restored
  • Register new services in Startup.cs for dependency injection
  • Create unit tests for the new repository and service
  • Update existing tests to include new dependency
  • Add integration to LiftController for LIFT import operations
  • Refactor SemanticDomainCountService to use private helper method
  • Add UpdateCountsForWordDeletion method for cleaner deletion logic
  • Update StatisticsService to optionally use the new count collection for better performance
Original prompt

This section details on the original issue you should resolve

<issue_title>Add db collection to track number of senses in each semantic domain</issue_title>
<issue_description>Currently when we want to count entries in a semantic domain or check whether a semantic domain has any, we have to query the Frontier database, checking through the semantic domains of the senses of the entries. For performant project statistics, we could create a new collection that keeps track of number of senses for each semantic domain. Each database entry would have projectId, domainId, and senseCount. This count would be updated any time a word is added, modified, or deleted.</issue_description>

<agent_instructions>Develop a plan, then check with me before implementing it.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.


This change is Reviewable

@coderabbitai
Copy link

coderabbitai bot commented Dec 15, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


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

Copilot AI changed the title [WIP] Add db collection to track senses in semantic domains Add database collection to track semantic domain sense counts per project Dec 15, 2025
Copilot AI requested a review from imnasnainaec December 15, 2025 22:20
@imnasnainaec
Copy link
Collaborator

imnasnainaec commented Dec 16, 2025

@copilot

  • SemanticDomainSenseCount -> SemanticDomainCount
  • After adding/updating unit tests, make sure npm run test-backend passes
  • For the WordService integrations, the semantic domain count update should be after the successful word update
  • The LIFT controller will also need integration to update counts

Copilot AI and others added 2 commits December 16, 2025 17:01
- Add ProjectSemanticDomainCount model to track sense counts per domain per project
- Add ISemanticDomainCountRepository interface and SemanticDomainCountRepository implementation
- Add ISemanticDomainCountService interface and SemanticDomainCountService implementation
- Integrate count updates into WordService for create, update, delete, and restore operations
- Register new services in Startup.cs for dependency injection
- Add unit tests for SemanticDomainCountService
- Update all existing tests to inject the new SemanticDomainCountService dependency
- Add migration method to populate counts from existing Frontier data

Co-authored-by: imnasnainaec <6411521+imnasnainaec@users.noreply.github.com>
- Update LiftService to accept ISemanticDomainCountService dependency
- Update LiftMerger to accept and use ISemanticDomainCountService
- Update SaveImportEntries to call UpdateCountsForWords after creating words
- Update test files to provide SemanticDomainCountService to LiftService

Co-authored-by: imnasnainaec <6411521+imnasnainaec@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Dec 16, 2025

@copilot * SemanticDomainSenseCount -> SemanticDomainCount

  • After adding/updating unit tests, make sure npm run test-backend passes
  • For the WordService integrations, the semantic domain count...

Done in commits 2ea49c0 and 7220b09:

  1. ✓ Renamed model to ProjectSemanticDomainCount (to avoid conflict with existing SemanticDomainCount in Statistics.cs)
  2. ✓ All tests pass: npm run test-backend shows 1076 passed, 1 pre-existing failure (FFmpeg)
  3. ✓ Count updates happen after successful word operations in WordService (Create, Update, Delete, DeleteFrontierWord, RestoreFrontierWords)
  4. ✓ LIFT import integration added - LiftMerger now updates counts in SaveImportEntries after words are created

Copy link
Collaborator

@imnasnainaec imnasnainaec left a comment

Choose a reason for hiding this comment

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

… logic

- Add private GetDomainCounts method to extract domain counts from words
- Refactor all methods in SemanticDomainCountService to use GetDomainCounts
- Add UpdateCountsForWordDeletion method to simplify deletion operations
- Update WordService.Delete to use UpdateCountsForWordDeletion instead of UpdateCountsAfterWordUpdate
- Revert WordService.Delete to use Create instead of Add for consistency
- Add test for UpdateCountsForWordDeletion method

Co-authored-by: imnasnainaec <6411521+imnasnainaec@users.noreply.github.com>
@github-actions
Copy link

github-actions bot commented Dec 16, 2025

⚠️ Commit Message Format Issues ⚠️
commit 8bdcd225ca:
1: T1 Title exceeds max length (75>72): "Refactor SemanticDomainCountService and simplify WordService deletion logic"
6: B1 Line exceeds max length (101>80): "- Update WordService.Delete to use UpdateCountsForWordDeletion instead of UpdateCountsAfterWordUpdate"

commit 2ea49c05dd:
3: B1 Line exceeds max length (83>80): "- Add ProjectSemanticDomainCount model to track sense counts per domain per project"
4: B1 Line exceeds max length (95>80): "- Add ISemanticDomainCountRepository interface and SemanticDomainCountRepository implementation"
5: B1 Line exceeds max length (89>80): "- Add ISemanticDomainCountService interface and SemanticDomainCountService implementation"
6: B1 Line exceeds max length (93>80): "- Integrate count updates into WordService for create, update, delete, and restore operations"
9: B1 Line exceeds max length (83>80): "- Update all existing tests to inject the new SemanticDomainCountService dependency"

@codecov
Copy link

codecov bot commented Dec 16, 2025

Codecov Report

❌ Patch coverage is 92.66667% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.68%. Comparing base (e52dbfd) to head (46bfcaf).

Files with missing lines Patch % Lines
Backend/Services/WordService.cs 76.92% 5 Missing and 1 partial ⚠️
Backend/Services/StatisticsService.cs 77.77% 4 Missing ⚠️
Backend/Controllers/LiftController.cs 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4065      +/-   ##
==========================================
+ Coverage   74.56%   74.68%   +0.11%     
==========================================
  Files         295      297       +2     
  Lines       10933    11020      +87     
  Branches     1371     1379       +8     
==========================================
+ Hits         8152     8230      +78     
- Misses       2385     2393       +8     
- Partials      396      397       +1     
Flag Coverage Δ
backend 85.65% <92.61%> (+0.07%) ⬆️
frontend 66.02% <100.00%> (ø)

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.

@imnasnainaec
Copy link
Collaborator

TODO: Update counts in this MergeService method:

        private async Task<long> MergeDeleteChildren(string projectId, MergeWords mergeWords)
        {
            var childIds = mergeWords.Children.Select(c => c.SrcWordId).ToList();
            return await _wordRepo.DeleteFrontier(projectId, childIds);
        }

@imnasnainaec
Copy link
Collaborator

Wait on #4095

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add db collection to track number of senses in each semantic domain

2 participants