Skip to content

Commit c1d2325

Browse files
authored
SF-3662 Ensure that no books are trained on when none are selected (#3606)
1 parent c4a8e75 commit c1d2325

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

src/SIL.XForge.Scripture/Services/MachineProjectService.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,9 +1262,11 @@ .. corporaSyncInfo
12621262
.Select(s => new ParallelCorpusFilterConfig
12631263
{
12641264
CorpusId = s.CorpusId,
1265-
ScriptureRange = buildConfig
1266-
.TrainingScriptureRanges.FirstOrDefault(t => t.ProjectId == s.ProjectId)
1267-
?.ScriptureRange,
1265+
ScriptureRange =
1266+
buildConfig
1267+
.TrainingScriptureRanges.FirstOrDefault(t => t.ProjectId == s.ProjectId)
1268+
?.ScriptureRange
1269+
?? string.Empty,
12681270
}),
12691271
],
12701272
TargetFilters =
@@ -1294,9 +1296,8 @@ .. corporaSyncInfo
12941296
)
12951297
{
12961298
// Set the scripture range for the matching target filter
1297-
trainingCorpusConfig.TargetFilters[j].ScriptureRange = trainingCorpusConfig
1298-
.SourceFilters[j]
1299-
.ScriptureRange;
1299+
trainingCorpusConfig.TargetFilters[j].ScriptureRange =
1300+
trainingCorpusConfig.SourceFilters[j].ScriptureRange ?? string.Empty;
13001301
}
13011302
else if (trainingCorpusConfig.TargetFilters[0] is not null)
13021303
{
@@ -1314,10 +1315,10 @@ .. corporaSyncInfo
13141315
.Distinct()
13151316
);
13161317

1317-
// Ensure that the scripture range is null if it is empty, so that all books will be trained on
1318+
// Ensure that the scripture range is empty if it is null, so that no books will be trained on
13181319
if (string.IsNullOrWhiteSpace(trainingCorpusConfig.TargetFilters[0].ScriptureRange))
13191320
{
1320-
trainingCorpusConfig.TargetFilters[0].ScriptureRange = null;
1321+
trainingCorpusConfig.TargetFilters[0].ScriptureRange = string.Empty;
13211322
}
13221323
}
13231324
}

test/SIL.XForge.Scripture.Tests/Services/MachineProjectServiceTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1819,13 +1819,13 @@ public void GetTranslationBuildConfig_NoScriptureRange()
18191819
.SourceFilters!.Single(f => f.CorpusId == Corpus01)
18201820
.ScriptureRange
18211821
);
1822-
Assert.IsNull(
1822+
Assert.IsEmpty(
18231823
actual
18241824
.TrainOn!.Single(c => c.ParallelCorpusId == ParallelCorpus02)
18251825
.SourceFilters!.Single(f => f.CorpusId == Corpus03)
18261826
.ScriptureRange
18271827
);
1828-
Assert.IsNull(
1828+
Assert.IsEmpty(
18291829
actual
18301830
.TrainOn!.Single(c => c.ParallelCorpusId == ParallelCorpus02)
18311831
.TargetFilters!.Single(f => f.CorpusId == Corpus04)

0 commit comments

Comments
 (0)