-
Notifications
You must be signed in to change notification settings - Fork 4
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
검색 API 구현 #319
검색 API 구현 #319
Conversation
Application Server의 search api를 추가함에 따라 path alias를 추가했습니다.
Application Server에서 Search 모듈에서 사용할 조건별 멤버 검색 함수를 작성하였습니다.
검색에 대한 정보 제공을 위한 Application Server의 API를 추가하였습니다. 사용방법: [GET] api.funch.site/search?query=검색어
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
수고하셨습니다 ~~ 마지막 한 주 열심히 해봐욥
SearchModule, | ||
FollowModule, | ||
NaverAuthModule, | ||
GoogleAuthModule, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
점점 늘어가는 모듈들,,,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ㅠㅠ
@@ -12,19 +12,25 @@ class MemberService { | |||
private memberRepository: Repository<Member>, | |||
) {} | |||
|
|||
async findMembers() { | |||
findMembers() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
async를 빼신 이유가 있으실까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
await을 안써서 뺐습니다!
applicationServer/src/app.module.ts
Outdated
@@ -6,13 +6,23 @@ import { LiveModule } from '@live/live.module'; | |||
import { GithubAuthModule } from '@github/github.module'; | |||
import { AuthModule } from '@auth/auth.module'; | |||
import { FollowModule } from '@follow/follow.module'; | |||
import { SearchModule } from './search/search.module'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
path alias 적용해주세요 ..!!
@@ -0,0 +1,32 @@ | |||
import { Controller, Get, Query } from '@nestjs/common'; | |||
import { SearchService } from './search.service'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여기도 적용해주세요!
const keyword = query.replace(' ', ''); | ||
const searchResult = { | ||
lives: [], | ||
members: [], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이것도 on/off 같이 변수명을 더 직관적이게 만들면 좋을 것 같아요.
하지만 오전에 FE분들이랑 이미 명세에 관해서 얘기 나눠서 괜찮을 것 같네요!
|
||
@Get('/') | ||
async getSearchData(@Query('query') query: string) { | ||
const keyword = query.replace(' ', ''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
쿼리에서 공백을 없애는 이유가 있으신가요??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
검색 효율성을 위해 공백을 제거한 문자열 매칭으로 탐색하기 때문에 검색어에서도 공백을 제거했습니다.
|
||
getLiveListWithKeyword(keyword) { | ||
const currentLiveList = this.liveService.getLiveList(0); | ||
const filteredLiveList = currentLiveList.reduce((list, live) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
진영님 정말 reduce를 좋아하시고 또 잘 쓰시네요..!!
const metadata = [...live.tags, live.contentCategory, live.moodCategory, live.title, live.userName] | ||
.join('') | ||
.replace(' ', ''); | ||
if (metadata.match(new RegExp(keyword))) list.push(live); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아까 개발일지를 봤었는데, kmp 알고리즘과 정규표현식의 비교를 통해 정규표현식으로 결정하셨네요!
비교까지 👍🏻👍🏻 좋습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
사실 kmp가 당연히 더 빠를 줄 알았는데 느려서 조금 당황스럽긴 하네요..
Application Server의 search 모듈에서 import에 path alias를 적용하도록 변경하였습니다.
Issue
Detail
추가했습니다.
작성하였습니다.
사용방법:
[GET] api.funch.site/search?query=검색어