Skip to content

Commit

Permalink
[FIX] 회원 가입시 노션 순서 보장 (#725)
Browse files Browse the repository at this point in the history
* feat: 회원 가입시 최초 북마크 생성 로직

* fix: 픽 쿼리 빈 배열 예외 추가

* feat: 추천 링크 클릭 이벤트 추가

* refactor: 단순 클래스 이름 변경

* refactor: 단순 미사용 메서드 제거

* refactor: 단순 클래스 이름 변경

* fix: 회원 가입 시 폴더 생성 순서 변경

* feat: 추천 링크 클릭 이벤트 추가

* fix: 노션 메뉴얼을 제일 마지막에 넣도록 순서 수정
  • Loading branch information
kimminkyeu authored Dec 10, 2024
1 parent 96eab89 commit 520ab8a
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 37 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package techpick.api.domain.user.service.strategy;

import techpick.core.model.folder.Folder;
import techpick.core.model.user.User;

public interface ContentInitStrategy {
void initContent(User user, Folder parentFolder);
void initContent(User user, Long folderId);
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ public class ManualInitStrategy implements ContentInitStrategy {
);

@Override
public void initContent(User user, Folder parentFolder) {
public void initContent(User user, Long folderId) {
for (var url : MANUAL_URLS) {
var linkInfo = linkService.saveLinkAndUpdateOgTag(url);
var command = new PickCommand.Create(
user.getId(), linkInfo.title(), new ArrayList<>(), parentFolder.getId(), linkInfo
user.getId(), linkInfo.title(), new ArrayList<>(), folderId, linkInfo
);
pickService.saveNewPick(command);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import techpick.api.domain.pick.service.PickService;
import techpick.api.infrastructure.ranking.RankingApi;
import techpick.core.dto.UrlWithCount;
import techpick.core.model.folder.Folder;
import techpick.core.model.user.User;

@Slf4j
Expand All @@ -32,14 +31,14 @@ public class RankingInitStrategy implements ContentInitStrategy {
private final LinkService linkService;

@Override
public void initContent(User user, Folder parentFolder) {
public void initContent(User user, Long folderId) {
var currentDay = LocalDate.now();
var before1Day = currentDay.minusDays(1);
var before30Days = currentDay.minusDays(30);
var monthlyRanking = rankingApi
.getUrlRankingByViewCount(before30Days, before1Day, LOAD_LIMIT)
.getBody();
savePickFromRankingList(user.getId(), monthlyRanking, parentFolder.getId());
savePickFromRankingList(user.getId(), monthlyRanking, folderId);
}

/**
Expand All @@ -55,6 +54,9 @@ private void savePickFromRankingList(Long userId, List<UrlWithCount> rankingList
var curr = reverseItr.previous();
try {
var linkInfo = linkService.getLinkInfo(curr.url());
if (linkInfo.title().isBlank()) {
continue;
}
var command = new PickCommand.Create(
userId, linkInfo.title(), new ArrayList<>(), destinationFolderId, linkInfo
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import techpick.api.domain.folder.dto.FolderCommand;
import techpick.api.domain.folder.service.FolderService;
import techpick.api.domain.link.service.LinkService;
import techpick.api.domain.pick.service.PickService;
import techpick.api.infrastructure.folder.FolderDataHandler;
import techpick.core.model.folder.Folder;
import techpick.core.model.user.User;
Expand All @@ -18,15 +21,14 @@ public class StarterFolderStrategy {

private static final String FOLDER_NAME = "시작하기";

private final FolderDataHandler folderDataHandler;

private final List<ContentInitStrategy> contentStrategies;
private final FolderDataHandler folderService;
private final RankingInitStrategy rankingInitStrategy;
private final ManualInitStrategy manualInitStrategy;

public void initFolder(User user, Folder parentFolder) {
var command = new FolderCommand.Create(user.getId(), FOLDER_NAME, parentFolder.getId());
var folder = folderDataHandler.saveFolder(command);
for (var strategy : contentStrategies) {
strategy.initContent(user, folder);
}
var createdFolder = folderService.saveFolder(command);
rankingInitStrategy.initContent(user, createdFolder.getId());
manualInitStrategy.initContent(user, createdFolder.getId());
}
}

0 comments on commit 520ab8a

Please sign in to comment.