Skip to content

Conversation

@josephmyers
Copy link
Collaborator

@josephmyers josephmyers commented Dec 17, 2025

This fixes a bug where deleted training files couldn't be found in the project, since their file name would be missing and the app wouldn't register that there was a training file associated with a build entry.


This change is Reviewable

@josephmyers josephmyers added the will require testing PR should not be merged until testers confirm testing is complete label Dec 17, 2025
@codecov
Copy link

codecov bot commented Dec 18, 2025

Codecov Report

❌ Patch coverage is 34.00000% with 33 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.75%. Comparing base (47ee299) to head (58bdba2).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...e.Scripture/Controllers/SFProjectsRpcController.cs 0.00% 22 Missing ⚠️
...L.XForge.Scripture/Services/TrainingDataService.cs 57.14% 4 Missing and 2 partials ⚠️
...ation/confirm-sources/confirm-sources.component.ts 25.00% 2 Missing and 1 partial ⚠️
...neration-steps/draft-generation-steps.component.ts 75.00% 0 Missing and 1 partial ⚠️
...eneration/draft-sources/draft-sources.component.ts 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3615      +/-   ##
==========================================
- Coverage   82.82%   82.75%   -0.07%     
==========================================
  Files         610      610              
  Lines       37400    37441      +41     
  Branches     6151     6154       +3     
==========================================
+ Hits        30976    30985       +9     
- Misses       5478     5518      +40     
+ Partials      946      938       -8     

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

This fixes a bug where deleted training files couldn't be found in the project, since their file name would be missing and the app wouldn't register that there was a training file associated with a build entry.
@josephmyers josephmyers changed the title Mark training file as deleted, instead of deleting SF-3663 Mark training file as deleted, instead of deleting Dec 18, 2025
@josephmyers josephmyers marked this pull request as ready for review December 18, 2025 16:37
@RaymondLuong3 RaymondLuong3 self-assigned this Dec 18, 2025
Copy link
Collaborator

@RaymondLuong3 RaymondLuong3 left a comment

Choose a reason for hiding this comment

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

This looks like it is compatible with older clients, which is a good thing. A few comments to address and additional tests are needed.

@RaymondLuong3 reviewed 18 files and all commit messages, and made 8 comments.
Reviewable status: all files reviewed, 7 unresolved discussions (waiting on @josephmyers).


src/SIL.XForge.Scripture/ClientApp/src/app/translate/draft-generation/confirm-sources/confirm-sources.component.ts line 64 at r1 (raw file):

              (this.trainingDataQuery?.docs
                .map(doc => doc.data)
                .filter(d => d != null && !d.deleted) as TrainingData[]) ?? [];

When deleted is optional, this needs to consider filter the case when deleted != true

Code quote:

filter(d => d != null && !d.deleted) as TrainingData[]) ?? [];

src/RealtimeServer/scriptureforge/models/training-data.ts line 16 at r1 (raw file):

  skipRows: number;
  title: string;
  deleted: boolean;

This should be optional, otherwise you will have to migrate all training data records in the db

Code quote:

  deleted: boolean;

src/SIL.XForge.Scripture/Controllers/SFProjectsRpcController.cs line 710 at r1 (raw file):

    }

    public async Task<IRpcMethodResult> MarkTrainingDataDeleted(string projectId, string dataId)

It should be straight forward to fill in the missing tests for this controller.

Code quote:

    public async Task<IRpcMethodResult> MarkTrainingDataDeleted(string projectId, string dataId)

src/SIL.XForge.Scripture/ClientApp/src/app/translate/draft-generation/draft-sources/draft-sources.component.ts line 188 at r1 (raw file):

        this.savedTrainingFiles =
          this.trainingDataQuery?.docs.filter(d => d.data != null && !d.data.deleted).map(d => d.data!) ?? [];

Filter only the case where deleted != true`

Code quote:

(d => d.data != null && !d.data.deleted

test/SIL.XForge.Scripture.Tests/Services/TrainingDataServiceTests.cs line 505 at r1 (raw file):

    [Test]
    public async Task MarkFileDeleted_SetsDeletedFlag()

You will want to add tests for when the file is not found. I can see that happening.

Code quote:

    public async Task MarkFileDeleted_SetsDeletedFlag()

test/SIL.XForge.Scripture.Tests/Services/TrainingDataServiceTests.cs line 507 at r1 (raw file):

    public async Task MarkFileDeleted_SetsDeletedFlag()
    {
        var env = new TestEnvironment();

I would also assert that training data is not deleted before calling MarkFileDeleted

Code quote:

 var env = new TestEnvironment();

src/SIL.XForge.Scripture/ClientApp/src/app/translate/draft-generation/draft-history-list/draft-history-list.component.spec.ts line 37 at r1 (raw file):

      provideTestRealtime(SF_TYPE_REGISTRY),
      provideHttpClient(withFetch()),
      provideHttpClientTesting(),

Are these changes necessary?

Code quote:

      provideHttpClient(withFetch()),
      provideHttpClientTesting(),

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

Labels

will require testing PR should not be merged until testers confirm testing is complete

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants