Skip to content

Commit

Permalink
[TDC-47] 비로그인 상태에서 성능 개선
Browse files Browse the repository at this point in the history
  • Loading branch information
yerimkoko committed Jan 29, 2024
1 parent 024cc70 commit e8b4828
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public ApiResponse<String> createReaction(@Valid @RequestBody AddReactionRequest
public ApiResponse<List<TargetStickerAction>> getTargetStickerReactions(@PathVariable StickerGroup stickerGroup,
@RequestParam Set<String> targetIds,
@RequestParam(required = false) String accountId) {
return ApiResponse.success(stickerFacadeService.getTargetStickerReactionResponse(stickerGroup, accountId, targetIds));
return ApiResponse.success(stickerFacadeService.getTargetStickers(stickerGroup, accountId, targetIds));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
import com.threedollar.service.sticker.dto.response.TargetStickerAction;
import com.threedollar.service.sticker.dto.request.AddReactionRequest;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -50,10 +52,10 @@ public void upsertSticker(AddReactionRequest request, StickerGroup stickerGroup,
}

@Transactional(readOnly = true)
public List<TargetStickerAction> getStickerReactionResponse(StickerGroup stickerGroup,
String accountId,
Set<String> targetIds,
List<Sticker> stickers) {
public List<TargetStickerAction> getStickerActionResponse(StickerGroup stickerGroup,
String accountId,
Set<String> targetIds,
List<Sticker> stickers) {

Map<StickerActionCountKey, Long> stickerCountKeyLongMap = getStickerCountKey(stickerGroup, targetIds, stickers);

Expand Down Expand Up @@ -93,6 +95,9 @@ private Map<StickerActionCountKey, Long> getStickerCountKey(StickerGroup sticker
private Map<String, StickerAction> getTargetIdActedByMe(Set<String> targetIds,
String accountId,
StickerGroup stickerGroup) {
if (StringUtils.isBlank(accountId)) {
return Collections.emptyMap();
}
List<StickerAction> stickerActions = stickerActionRepository.getStickerActionByMe(accountId, targetIds, stickerGroup);
return stickerActions.stream()
.collect(Collectors.toMap(StickerAction::getTargetId, stickerAction -> stickerAction));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ public void upsertSticker(AddReactionRequest request, @NotNull StickerGroup stic
}


public List<TargetStickerAction> getTargetStickerReactionResponse(@NotNull StickerGroup stickerGroup, String accountId, Set<String> targetIds) {
public List<TargetStickerAction> getTargetStickers(@NotNull StickerGroup stickerGroup, String accountId, Set<String> targetIds) {
List<Sticker> stickers = stickerService.getStickersByStickerGroup(stickerGroup);
return stickerActionService.getStickerReactionResponse(stickerGroup, accountId, targetIds, stickers);
return stickerActionService.getStickerActionResponse(stickerGroup, accountId, targetIds, stickers);
}


Expand Down

0 comments on commit e8b4828

Please sign in to comment.