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

meme 인터렉션 생성될때 밈 업데이트도 되도록 #60

Merged
merged 1 commit into from
Oct 4, 2024
Merged
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
2 changes: 1 addition & 1 deletion src/routes/meme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ router.get('/list', getRequestedUserInfo, getAllMemeList); // meme 목록 전체
* type: null
* example: null
*/
router.get('/recommend-memes', getRequestedUserInfo, getLatestMemeList); // 오늘의 추천 밈 (5개)
router.get('/recommend-memes', getRequestedUserInfo, getLatestMemeList); // 오늘의 추천 밈 (20개)

/**
* @swagger
Expand Down
16 changes: 8 additions & 8 deletions src/service/meme.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ async function getLatestCreatedMeme(
try {
const latestMemeList = await MemeModel.find({ isDeleted: false }, { isDeleted: 0 })
.limit(limit)
.sort({_id: -1})
.sort({ _id: -1 })
.lean();

const memeList = await getMemeListWithKeywordsAndisSavedAndisReaction(user, latestMemeList);
Expand Down Expand Up @@ -311,14 +311,14 @@ async function createMemeInteraction(
if (_.isNull(memeInteraction)) {
// 신규 생성
await MemeInteractionService.createMemeInteraction(user, meme, interactionType);
} else {
logger.info(
`Already ${interactionType} meme - deviceId(${user.deviceId}), memeId(${meme._id})`,
);

// interactionType에 따른 동작 처리 (MemeInteracionService에서 진행)
await MemeInteractionService.updateMemeInteraction(user, meme, interactionType, count);
}
logger.info(
`Already ${interactionType} meme - deviceId(${user.deviceId}), memeId(${meme._id})`,
);

// interactionType에 따른 동작 처리 (MemeInteracionService에서 진행)
await MemeInteractionService.updateMemeInteraction(user, meme, interactionType, count);

return true;
} catch (err) {
throw new CustomError(
Expand Down
1 change: 0 additions & 1 deletion src/service/memeInteraction.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ async function updateMemeInteraction(
break;

// 'reaction' Meme.reaction count 올리기
// User의 'reaction' count는 밈당 1번
case InteractionType.REACTION:
await MemeModel.findOneAndUpdate(
{ _id: meme._id, isDeleted: false },
Expand Down