Skip to content

Commit

Permalink
I18N-1327 - search by location / usages throws timeout error (#173)
Browse files Browse the repository at this point in the history
Removed asset path condition for location/usages filtering
  • Loading branch information
DarKhaos authored Oct 28, 2024
1 parent 0fc92e8 commit feef899
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 60 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import com.box.l10n.mojito.nativecriteria.NativeInExpFix;
import com.box.l10n.mojito.nativecriteria.NativeInSubQueryExp;
import com.box.l10n.mojito.nativecriteria.NativeNotILikeExp;
import com.box.l10n.mojito.nativecriteria.NativeNotInSubQueryExp;
import com.github.pnowy.nc.core.CriteriaResult;
import com.github.pnowy.nc.core.NativeCriteria;
import com.github.pnowy.nc.core.NativeExps;
Expand Down Expand Up @@ -136,18 +135,6 @@ public List<TextUnitDTO> search(TextUnitSearcherParameters searchParameters) {

private void addLocationUsageExp(
TextUnitSearcherParameters searchParameters, NativeJunctionExp conjunction) {
NativeJunctionExp usageExp = NativeExps.disjunction();

NativeCriteria allUsages =
new NativeCriteria(new JpaQueryProvider(), "asset_text_unit_usages", "atuu");
allUsages.setDistinct(true);
allUsages.setProjection(NativeExps.projection().addProjection("atuu.asset_text_unit_id"));
NativeJunctionExp assetPathUsageConjunction = NativeExps.conjunction();
assetPathUsageConjunction.add(new NativeNotInSubQueryExp("atu.id", allUsages));
assetPathUsageConjunction.add(
getSearchTypeNativeExp(
searchParameters.getSearchType(), "a.path", searchParameters.getLocationUsage()));
usageExp.add(assetPathUsageConjunction);

NativeCriteria usage =
new NativeCriteria(new JpaQueryProvider(), "asset_text_unit_usages", "atuu");
Expand All @@ -158,9 +145,8 @@ private void addLocationUsageExp(
getSearchTypeNativeExp(
searchParameters.getSearchType(), "atuu.usages", searchParameters.getLocationUsage()));
usage.add(usageConjunction);
usageExp.add(new NativeInSubQueryExp("atu.id", usage));

conjunction.add(usageExp);
conjunction.add(new NativeInSubQueryExp("atu.id", usage));
}

NativeCriteria getCriteriaForSearch(TextUnitSearcherParameters searchParameters) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ public void testAllFilters() {
textUnitSearcherParameters.setSource("Please enter a valid state, region or province");
textUnitSearcherParameters.setUsedFilter(UsedFilter.USED);
textUnitSearcherParameters.setStatusFilter(StatusFilter.TRANSLATED);
textUnitSearcherParameters.setLocationUsage("fake_for_test");

List<TextUnitDTO> textUnitDTOs = textUnitSearcher.search(textUnitSearcherParameters);

Expand All @@ -112,7 +111,6 @@ public void testAllFilters() {
tmTestData.addCurrentTMTextUnitVariant1KoKR.getId(), next.getTmTextUnitVariantId());
assertTrue(next.isTranslated());
assertTrue(next.isUsed());
assertEquals("fake_for_test", next.getAssetPath());

assertFalse(iterator.hasNext());
}
Expand Down Expand Up @@ -813,21 +811,6 @@ public void testILikeSearchTarget() {
"Content3 fr-FR"));
}

@Test
public void testExactMatchLocationUsageByAssetPath() {
testSearchText("assetPath", "fake_for_test", SearchType.EXACT, List.of("fake_for_test"));
}

@Test
public void testContainsLocationUsageByAssetPath() {
testSearchText("assetPath", "fake", SearchType.CONTAINS, List.of("fake_for_test"));
}

@Test
public void testILikeLocationUsageByAssetPath() {
testSearchText("assetPath", "%FAKE_FOR_%test", SearchType.ILIKE, List.of("fake_for_test"));
}

@Test
public void testExactMatchLocationUsageByUsages() {
testSearchText("usage", "usage_test", SearchType.EXACT, List.of("usage_test"), true);
Expand Down Expand Up @@ -933,7 +916,7 @@ public void testSearchText(
textUnitSearcherParameters.setSource(value);
} else if ("target".equals(attribute)) {
textUnitSearcherParameters.setTarget(value);
} else if ("usage".equals(attribute) || "assetPath".equals(attribute)) {
} else if ("usage".equals(attribute)) {
textUnitSearcherParameters.setLocationUsage(value);
} else {
throw new RuntimeException();
Expand Down Expand Up @@ -962,8 +945,6 @@ public void testSearchText(
attributeToCheck = textUnitDTO.getSource();
} else if ("target".equals(attribute)) {
attributeToCheck = textUnitDTO.getTarget();
} else if ("assetPath".equals(attribute)) {
attributeToCheck = textUnitDTO.getAssetPath();
} else {
Optional<String> optionalUsage =
assetTextUnitToTMTextUnits.stream()
Expand Down

0 comments on commit feef899

Please sign in to comment.