Skip to content

Commit

Permalink
Merge pull request #60 from mash-up-kr/FIX/INTERACTION
Browse files Browse the repository at this point in the history
meme 인터렉션 생성될때 밈 업데이트도 되도록
  • Loading branch information
Hyun-git authored Oct 4, 2024
2 parents 8db5b4c + 92db177 commit 0daf210
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
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

0 comments on commit 0daf210

Please sign in to comment.