Skip to content

Commit

Permalink
fix: 검색 api 버그 수정 (#373)
Browse files Browse the repository at this point in the history
* fix: 검색 api 버그 수정

* ci: ci/cd 파일 변경

* ci: ci/cd 파일 변경
  • Loading branch information
seheonnn authored Aug 16, 2024
1 parent e46c766 commit c7b130d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci_gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
shell: bash

- name: Start Docker Compose
run: docker-compose -f docker-compose-test.yml up -d
run: docker compose up -d

- name: Grant execute permission for gradlew
run: chmod +x gradlew
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public ApiResponse<PageResponse<OrganizationSearchResponse>> searchOrganization(
@AuthOrganization Organization organization
) {
return ApiResponse.onSuccess(
organizationQueryService.searchOrganizations(pageCondition, keyword, organization));
organizationQueryService.searchOrganizationsV2(pageCondition, keyword, organization));
}

@DeleteMapping("/search")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.sponus.coredomain.domain.bookmark.repository.BookmarkRepository;
import com.sponus.coredomain.domain.organization.Organization;
import com.sponus.coredomain.domain.organization.enums.OrganizationType;
import com.sponus.coredomain.domain.organization.enums.ProfileStatus;
Expand All @@ -36,6 +37,7 @@ public class OrganizationQueryService {

private final OrganizationRepository organizationRepository;
private final SearchHistoryRepository searchHistoryRepository;
private final BookmarkRepository bookmarkRepository;

public Boolean verifyName(String name) {
return organizationRepository.existsByName(name);
Expand All @@ -46,10 +48,10 @@ public PageResponse<OrganizationGetResponse> getOrganizations(
PageCondition pageCondition,
OrganizationType organizationType) {
// TODO: FETCH JOIN으로 변경
Set<Long> bookmarkedOrganizationIds = authOrganization.getBookmarks()
.stream()
.map(bookmark -> bookmark.getTarget().getId())
Set<Long> bookmarkedOrganizationIds = bookmarkRepository.findByOrganization(authOrganization).stream()
.map((bookmark) -> bookmark.getTarget().getId())
.collect(Collectors.toSet());

Pageable pageable = PageRequest.of(pageCondition.getPage() - 1, pageCondition.getSize());
List<OrganizationGetResponse> organizations = organizationRepository.findOrganizations(
organizationType, pageable, authOrganization.getId())
Expand All @@ -66,10 +68,10 @@ public PageResponse<OrganizationGetResponse> getOrganizations(
public PageResponse<OrganizationSearchResponse> searchOrganizations(PageCondition pageCondition, String keyword,
Organization authOrganization) {

Set<Long> bookmarkedOrganizationIds = authOrganization.getBookmarks()
.stream()
.map(bookmark -> bookmark.getTarget().getId())
Set<Long> bookmarkedOrganizationIds = bookmarkRepository.findByOrganization(authOrganization).stream()
.map((bookmark) -> bookmark.getTarget().getId())
.collect(Collectors.toSet());

Pageable pageable = PageRequest.of(pageCondition.getPage() - 1, pageCondition.getSize());

List<OrganizationSearchResponse> organizations = organizationRepository.findByNameContains(
Expand All @@ -95,9 +97,8 @@ public PageResponse<OrganizationSearchResponse> searchOrganizationsV2(

Page<Organization> organizations = organizationRepository.searchOrganizationV2(condition, pageable);

Set<Long> bookmarkedOrganizationIds = authOrganization.getBookmarks()
.stream()
.map(bookmark -> bookmark.getTarget().getId())
Set<Long> bookmarkedOrganizationIds = bookmarkRepository.findByOrganization(authOrganization).stream()
.map((bookmark) -> bookmark.getTarget().getId())
.collect(Collectors.toSet());

return PageResponse.of(organizations.map(organization ->
Expand Down

0 comments on commit c7b130d

Please sign in to comment.