From 5f73f333a1167b43793db80db45d40b9fed3908f Mon Sep 17 00:00:00 2001 From: Mark Allen <3417310+maallen@users.noreply.github.com> Date: Thu, 10 Aug 2023 13:56:15 +0100 Subject: [PATCH] Set json sync push to be ordered --- .../mojito/entity/ThirdPartyFileChecksum.java | 4 +-- .../thirdparty/ThirdPartyTMSSmartling.java | 31 +++++++++++-------- .../ThirdPartyTMSSmartlingWithJson.java | 1 + .../V64__third_party_sync_file_checksum.sql | 3 +- 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/webapp/src/main/java/com/box/l10n/mojito/entity/ThirdPartyFileChecksum.java b/webapp/src/main/java/com/box/l10n/mojito/entity/ThirdPartyFileChecksum.java index 3c4b929866..23679d915f 100644 --- a/webapp/src/main/java/com/box/l10n/mojito/entity/ThirdPartyFileChecksum.java +++ b/webapp/src/main/java/com/box/l10n/mojito/entity/ThirdPartyFileChecksum.java @@ -13,8 +13,8 @@ name = "third_party_sync_file_checksum", indexes = { @Index( - name = "UK__THIRD_PARTY_FILE_CHECKSUM__REPOSITORY_ID__FILE_NAME", - columnList = "repository_id, file_name", + name = "I__THIRD_PARTY__CHECKSUM__REPOSITORY_ID__FILE_NAME__LOCALE_ID", + columnList = "repository_id, locale_id, file_name", unique = true), }) public class ThirdPartyFileChecksum implements Serializable { diff --git a/webapp/src/main/java/com/box/l10n/mojito/service/thirdparty/ThirdPartyTMSSmartling.java b/webapp/src/main/java/com/box/l10n/mojito/service/thirdparty/ThirdPartyTMSSmartling.java index dd78db8b89..be2f69dff8 100644 --- a/webapp/src/main/java/com/box/l10n/mojito/service/thirdparty/ThirdPartyTMSSmartling.java +++ b/webapp/src/main/java/com/box/l10n/mojito/service/thirdparty/ThirdPartyTMSSmartling.java @@ -912,7 +912,7 @@ private Stream> partitionSingulars( String localeTag, String skipTextUnitsWithPattern, String skipAssetsWithPathPattern) { - return partitionedStream( + TextUnitSearcherParameters parameters = baseParams( repositoryId, localeTag, @@ -920,8 +920,9 @@ private Stream> partitionSingulars( skipAssetsWithPathPattern, true, true, - null), - textUnitSearcher::search); + null); + parameters.setOrdered(true); + return partitionedStream(parameters, textUnitSearcher::search); } private Stream> partitionSingulars( @@ -930,7 +931,7 @@ private Stream> partitionSingulars( String skipTextUnitsWithPattern, String skipAssetsWithPathPattern, String includeTextUnitWithPattern) { - return partitionedStream( + TextUnitSearcherParameters parameters = baseParams( repositoryId, localeTag, @@ -939,8 +940,9 @@ private Stream> partitionSingulars( true, true, null, - includeTextUnitWithPattern), - textUnitSearcher::search); + includeTextUnitWithPattern); + parameters.setOrdered(true); + return partitionedStream(parameters, textUnitSearcher::search); } private Stream> partitionPlurals( @@ -948,7 +950,7 @@ private Stream> partitionPlurals( String localeTag, String skipTextUnitsWithPattern, String skipAssetsWithPathPattern) { - return partitionedStream( + TextUnitSearcherParameters parameters = baseParams( repositoryId, localeTag, @@ -956,8 +958,9 @@ private Stream> partitionPlurals( skipAssetsWithPathPattern, false, false, - "%"), - textUnitSearcher::search); + "%"); + parameters.setOrdered(true); + return partitionedStream(parameters, textUnitSearcher::search); } private Stream> partitionPlurals( @@ -980,7 +983,7 @@ private Stream> partitionPlurals( .collect(Collectors.toList())); } - return partitionedStream( + TextUnitSearcherParameters parameters = baseParams( repositoryId, localeTag, @@ -989,8 +992,11 @@ private Stream> partitionPlurals( false, false, "%", - includeTextUnitsWithPattern), - searchFunction); + includeTextUnitsWithPattern); + + parameters.setOrdered(true); + + return partitionedStream(parameters, searchFunction); } private Stream> partitionedStream( @@ -1056,7 +1062,6 @@ private TextUnitSearcherParameters baseParams( result.setPluralFormsExcluded(pluralFormsExcluded); result.setSkipTextUnitWithPattern(skipTextUnitsWithPattern); result.setSkipAssetPathWithPattern(skipAssetsWithPathPattern); - result.setOrdered(true); if (!Strings.isNullOrEmpty(pluralFormOther)) { result.setPluralFormOther(pluralFormOther); } diff --git a/webapp/src/main/java/com/box/l10n/mojito/service/thirdparty/ThirdPartyTMSSmartlingWithJson.java b/webapp/src/main/java/com/box/l10n/mojito/service/thirdparty/ThirdPartyTMSSmartlingWithJson.java index 3e5a236767..fab0200d85 100644 --- a/webapp/src/main/java/com/box/l10n/mojito/service/thirdparty/ThirdPartyTMSSmartlingWithJson.java +++ b/webapp/src/main/java/com/box/l10n/mojito/service/thirdparty/ThirdPartyTMSSmartlingWithJson.java @@ -362,6 +362,7 @@ PageFetcherOffsetAndLimitSplitIterator getSourceTextUnitIterator( parameters.setOffset(offset); parameters.setLimit(limit); parameters.setPluralFormsFiltered(true); + parameters.setOrdered(true); List search = textUnitSearcher.search(parameters); return search; }, diff --git a/webapp/src/main/resources/db/migration/V64__third_party_sync_file_checksum.sql b/webapp/src/main/resources/db/migration/V64__third_party_sync_file_checksum.sql index 4bfacdfab9..a8a8787b4f 100644 --- a/webapp/src/main/resources/db/migration/V64__third_party_sync_file_checksum.sql +++ b/webapp/src/main/resources/db/migration/V64__third_party_sync_file_checksum.sql @@ -1,3 +1,4 @@ create table third_party_sync_file_checksum (repository_id bigint not null, locale_id bigint not null, checksum char(32) not null, file_name varchar(255) not null); alter table third_party_sync_file_checksum add constraint FK__THIRD_PARTY_CHECKSUM__REPO__ID foreign key (repository_id) references repository (id); -alter table third_party_sync_file_checksum add constraint FK__THIRD_PARTY_CHECKSUM__LOCALE__ID foreign key (locale_id) references locale (id); \ No newline at end of file +alter table third_party_sync_file_checksum add constraint FK__THIRD_PARTY_CHECKSUM__LOCALE__ID foreign key (locale_id) references locale (id); +create index I__THIRD_PARTY__CHECKSUM__REPOSITORY_ID__FILE_NAME__LOCALE_ID on third_party_sync_file_checksum(repository_id, locale_id, file_name) \ No newline at end of file