Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I18N-1327 - search by location / usages throws timeout error #173

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

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