chore: code split for entity search (#31332)
## Description > Code split for entity search. > 1. Move the methods to SearchEntityHelper to be readily available for re-use. > 2. Rename SearchEntitySolutionTest -> SearchEntitySolutionCETest #### PR fixes following issue(s) Fixes [[Task]: Add search functionality for workflows #30843](https://github.com/appsmithorg/appsmith/issues/30843) #### Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video > > #### Type of change - Chore (housekeeping or task changes that don't impact user perception) ## Testing > #### How Has This Been Tested? > None, as this is just a refactor. #### Test Plan > Add Testsmith test cases links that relate to this PR > > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Refactor** - Improved code efficiency in search functionality by centralizing the logic for creating pageable and sort objects. - **Tests** - Renamed a test class to better reflect its purpose. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Nilesh Sarupriya <20905988+nsarupr@users.noreply.github.com>
This commit is contained in:
parent
d25ae858e9
commit
f715cfd502
|
|
@ -19,6 +19,8 @@ import reactor.core.publisher.Mono;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.appsmith.server.searchentities.helpers.SearchEntityHelper.getPageable;
|
||||||
|
import static com.appsmith.server.searchentities.helpers.SearchEntityHelper.getSort;
|
||||||
import static com.appsmith.server.searchentities.helpers.SearchEntityHelper.shouldSearchEntity;
|
import static com.appsmith.server.searchentities.helpers.SearchEntityHelper.shouldSearchEntity;
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
|
|
@ -55,8 +57,8 @@ public class SearchEntitySolutionCEImpl implements SearchEntitySolutionCE {
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
return Mono.just(new SearchEntityDTO());
|
return Mono.just(new SearchEntityDTO());
|
||||||
}
|
}
|
||||||
Pageable pageable = Pageable.ofSize(size).withPage(page);
|
Pageable pageable = getPageable(page, size);
|
||||||
Sort sort = Sort.by(Sort.Direction.DESC, FieldName.UPDATED_AT);
|
Sort sort = getSort();
|
||||||
searchString = StringUtils.hasLength(searchString) ? searchString.trim() : "";
|
searchString = StringUtils.hasLength(searchString) ? searchString.trim() : "";
|
||||||
// If no entities are specified, search for all entities.
|
// If no entities are specified, search for all entities.
|
||||||
Mono<List<Workspace>> workspacesMono = Mono.just(new ArrayList<>());
|
Mono<List<Workspace>> workspacesMono = Mono.just(new ArrayList<>());
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,9 @@
|
||||||
package com.appsmith.server.searchentities.helpers;
|
package com.appsmith.server.searchentities.helpers;
|
||||||
|
|
||||||
|
import com.appsmith.server.constants.FieldName;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.data.domain.Sort;
|
||||||
|
|
||||||
public class SearchEntityHelper {
|
public class SearchEntityHelper {
|
||||||
/**
|
/**
|
||||||
* This method checks if the entity should be searched based on the entities list provided. If the entities list is null or empty, then all entities are searched.
|
* This method checks if the entity should be searched based on the entities list provided. If the entities list is null or empty, then all entities are searched.
|
||||||
|
|
@ -19,4 +23,12 @@ public class SearchEntityHelper {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Sort getSort() {
|
||||||
|
return Sort.by(Sort.Direction.DESC, FieldName.UPDATED_AT);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Pageable getPageable(int page, int size) {
|
||||||
|
return Pageable.ofSize(size).withPage(page);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
class SearchEntitySolutionTest {
|
class SearchEntitySolutionCETest {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
ApplicationPageService applicationPageService;
|
ApplicationPageService applicationPageService;
|
||||||
Loading…
Reference in New Issue
Block a user