Skip to content

Commit e02ccea

Browse files
committed
During batch import keep status only for string that are excluded
In current state it prevent to move string TRANSLATION_NEEDED to REVIEW_NEEDED/ACCEPTED We typically wanted the previous behavior to be able to marked false positive excluded as ACCEPTED, and missed error as excluded. With the new change this should still work, but we can move
1 parent 921726a commit e02ccea

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

webapp/src/main/java/com/box/l10n/mojito/service/oaitranslate/AiTranslateService.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,8 @@ public void aiTranslateNoBatch(AiTranslateInput aiTranslateInput, PollableTask c
429429
.filter(t -> t.textUnitDTOWithVariantComment() != null)
430430
.map(TextUnitDTOWithVariantCommentOrError::textUnitDTOWithVariantComment)
431431
.toList(),
432-
TextUnitBatchImporterService.IntegrityChecksType.KEEP_STATUS_IF_SAME_TARGET)
432+
TextUnitBatchImporterService.IntegrityChecksType
433+
.KEEP_STATUS_IF_SAME_TARGET_AND_NOT_INCLUDED)
433434
.stream()
434435
.collect(
435436
toMap(
@@ -851,7 +852,8 @@ List<String> importBatch(
851852
.filter(t -> t.error() == null)
852853
.map(TextUnitDTOWithVariantCommentOrError::textUnitDTOWithVariantComment)
853854
.toList(),
854-
TextUnitBatchImporterService.IntegrityChecksType.KEEP_STATUS_IF_SAME_TARGET);
855+
TextUnitBatchImporterService.IntegrityChecksType
856+
.KEEP_STATUS_IF_SAME_TARGET_AND_NOT_INCLUDED);
855857

856858
return forImport.stream()
857859
.filter(t -> t.error() != null)

webapp/src/main/java/com/box/l10n/mojito/service/thirdparty/ThirdPartyTMSPhrase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ public PollableFuture<Void> pull(
378378
OptionsParser optionsParser = new OptionsParser(optionList);
379379

380380
AtomicReference<IntegrityChecksType> integrityChecksType =
381-
new AtomicReference<>(IntegrityChecksType.KEEP_STATUS_IF_SAME_TARGET);
381+
new AtomicReference<>(IntegrityChecksType.KEEP_STATUS_IF_SAME_TARGET_AND_NOT_INCLUDED);
382382
optionsParser.getString(
383383
"integrityChecksType", s -> integrityChecksType.set(IntegrityChecksType.valueOf(s)));
384384

webapp/src/main/java/com/box/l10n/mojito/service/tm/importer/TextUnitBatchImporterService.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,13 @@ public enum IntegrityChecksType {
121121
*/
122122
KEEP_STATUS_IF_REJECTED_AND_SAME_TARGET,
123123
/**
124-
* Run integrity checks. If the target is the same, keep the current status.
124+
* Run integrity checks. If the target is the same and is not included in file then keep the
125+
* current status.
125126
*
126127
* <p>This is an extension of the legacy behavior that allows marking a translation as invalid
127128
* when the integrity check did not catch the issue, eventually causing a build failure.
128129
*/
129-
KEEP_STATUS_IF_SAME_TARGET;
130+
KEEP_STATUS_IF_SAME_TARGET_AND_NOT_INCLUDED;
130131

131132
public static IntegrityChecksType fromLegacy(
132133
boolean integrityCheckSkipped, boolean integrityCheckKeepStatusIfFailedAndSameTarget) {
@@ -418,10 +419,17 @@ void applyIntegrityChecks(
418419
textUnitForBatchImport.getContent().equals(currentTextUnit.getTarget());
419420

420421
if (hasSameTarget
421-
&& IntegrityChecksType.KEEP_STATUS_IF_SAME_TARGET.equals(integrityChecksType)) {
422+
&& IntegrityChecksType.KEEP_STATUS_IF_SAME_TARGET_AND_NOT_INCLUDED.equals(
423+
integrityChecksType)) {
424+
422425
textUnitForBatchImport.setIncludedInLocalizedFile(
423426
currentTextUnit.isIncludedInLocalizedFile());
424-
textUnitForBatchImport.setStatus(currentTextUnit.getStatus());
427+
428+
// we always keep the included flag, but we allow the status to change from TRANSLATION_NEED
429+
// to REVIEW_NEEDED to ACCEPTED
430+
if (currentTextUnit.isIncludedInLocalizedFile()) {
431+
textUnitForBatchImport.setStatus(currentTextUnit.getStatus());
432+
}
425433
}
426434

427435
for (TextUnitIntegrityChecker textUnitChecker : textUnitCheckers) {
@@ -454,7 +462,7 @@ void applyIntegrityChecks(
454462
.contains(FALSE_POSITIVE_TAG_FOR_STATUS)) {
455463
break;
456464
}
457-
case KEEP_STATUS_IF_SAME_TARGET:
465+
case KEEP_STATUS_IF_SAME_TARGET_AND_NOT_INCLUDED:
458466
case KEEP_STATUS_IF_REJECTED_AND_SAME_TARGET:
459467
textUnitForBatchImport.setIncludedInLocalizedFile(
460468
currentTextUnit.isIncludedInLocalizedFile());

0 commit comments

Comments
 (0)