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

검색 기능 구현 #45

Merged
merged 9 commits into from
Sep 25, 2024
Merged

검색 기능 구현 #45

merged 9 commits into from
Sep 25, 2024

Conversation

seohyun0120
Copy link
Collaborator

@seohyun0120 seohyun0120 commented Sep 18, 2024

  • 사용자들이 '검색어'를 입력해서 검색할 수 있도록 검색 기능 추가
  • 검색어 입력하여 검색(새로 추가): /api/meme/search?q={term}
    • title, source에 검색어가 포함되어있으면 검색 결과에 다 포함되도록 함
    • keyword에 검색어가 포함되어있으면 검색 결과에 다 포함!
  • 키워드 선택하여 검색(현행 유지): /api/meme/search/{name}
    • 키워드명이 100% 일치해야 검색됨
  • 테스트코드 추가

@seohyun0120 seohyun0120 self-assigned this Sep 18, 2024
@seohyun0120 seohyun0120 changed the base branch from main to develop September 18, 2024 11:59
} from '../controller/meme.controller';
import {
getRequestedMemeInfo,
getKeywordInfoByName,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 미들웨어 왜 controller 부분으로 이동한거야 ??

Copy link
Collaborator Author

@seohyun0120 seohyun0120 Sep 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

앗 정확히는
기존 검색 API에서는 키워드를 선택해서 검색 결과를 받아오는 (반쪽짜리 검색) 방식이어서, 미들웨어 단에서 해당 키워드가 있는지 검증해줬었는데,
피처를 추가하게 되면서 검색 API에서 검색어로 검색 결과를 받아오는 방식이 추가되었어

컨트롤러 단에서 키워드 방식인 경우에만 해당 검증을 하도록 변경한거야!

@@ -59,7 +59,7 @@ const MemeSchema: Schema = new Schema(
keywordIds: { type: [Types.ObjectId], ref: 'Keyword', required: true, default: [] },
image: { type: String, required: true },
reaction: { type: Number, required: true, default: 0 },
source: { type: String, required: true },
source: { type: String, default: '' },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

피그마에서는 필수로 표시되어있던 거 같은데 상관없나 ???

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

앗 이게 백오피스때문에 필수 빼뒀던 것 같은데.. 다시 required 옵션 추가했어요~

@@ -177,6 +177,24 @@ async function getRecommendedKeywords(): Promise<
}
}

async function getSearchedKeywords(term: string): Promise<Types.ObjectId[]> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기로 이동했구낭

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 함수는 getKeywordInfoByName 이 함수랑 동작이 조금 달라!
이건 regex 써서 해당 글자가 포함되어 있는지 검색하고 getKeywordInfoByName는 완벽히 일치하는 도큐먼트만 반환해

Copy link
Member

@Hyun-git Hyun-git left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

확인은 옛날에 했는데 approve를 안했네 쏘링,,,

@Hyun-git Hyun-git merged commit 7007a78 into develop Sep 25, 2024
1 check passed
@seohyun0120 seohyun0120 deleted the feature/search branch October 2, 2024 02:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants