Skip to content

Commit 01c1eb2

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 01c1eb2

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-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: 16 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,20 @@ 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+
425+
// We always keep the includedInLocalizedFile flag
422426
textUnitForBatchImport.setIncludedInLocalizedFile(
423427
currentTextUnit.isIncludedInLocalizedFile());
424-
textUnitForBatchImport.setStatus(currentTextUnit.getStatus());
428+
429+
// If the text unit is includedInLocalizedFile, we allow its status to change.
430+
// Otherwise (if not included), we keep the current status as is.
431+
// This supports status changes from TRANSLATION_NEEDED to REVIEW_NEEDED to ACCEPTED,
432+
// but only if the translation was not flagged as bad.
433+
if (!currentTextUnit.isIncludedInLocalizedFile()) {
434+
textUnitForBatchImport.setStatus(currentTextUnit.getStatus());
435+
}
425436
}
426437

427438
for (TextUnitIntegrityChecker textUnitChecker : textUnitCheckers) {
@@ -454,7 +465,7 @@ void applyIntegrityChecks(
454465
.contains(FALSE_POSITIVE_TAG_FOR_STATUS)) {
455466
break;
456467
}
457-
case KEEP_STATUS_IF_SAME_TARGET:
468+
case KEEP_STATUS_IF_SAME_TARGET_AND_NOT_INCLUDED:
458469
case KEEP_STATUS_IF_REJECTED_AND_SAME_TARGET:
459470
textUnitForBatchImport.setIncludedInLocalizedFile(
460471
currentTextUnit.isIncludedInLocalizedFile());

0 commit comments

Comments
 (0)