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

검색 API 구현 #319

Merged
merged 4 commits into from
Dec 2, 2024
Merged

검색 API 구현 #319

merged 4 commits into from
Dec 2, 2024

Conversation

JYKIM317
Copy link
Collaborator

@JYKIM317 JYKIM317 commented Dec 1, 2024

Issue



Detail

  • Application Server의 search api를 추가함에 따라 path alias를
    추가했습니다.
  • Application Server에서 Search 모듈에서 사용할 조건별 멤버 검색 함수를
    작성하였습니다.
  • 검색에 대한 정보 제공을 위한 Application Server의 API를 추가하였습니다.
    사용방법: [GET] api.funch.site/search?query=검색어

Application Server의 search api를 추가함에 따라 path alias를
추가했습니다.
Application Server에서 Search 모듈에서 사용할 조건별 멤버 검색 함수를
작성하였습니다.
검색에 대한 정보 제공을 위한 Application Server의 API를 추가하였습니다.
사용방법: [GET] api.funch.site/search?query=검색어
@JYKIM317 JYKIM317 added feature ✨ 기능 개발 be 🐿️ 백엔드 labels Dec 1, 2024
@JYKIM317 JYKIM317 requested a review from zzawang December 1, 2024 19:45
@JYKIM317 JYKIM317 self-assigned this Dec 1, 2024
@JYKIM317 JYKIM317 linked an issue Dec 1, 2024 that may be closed by this pull request
Copy link
Member

@zzawang zzawang left a 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,
Copy link
Member

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.

ㅠㅠ

@@ -12,19 +12,25 @@ class MemberService {
private memberRepository: Repository<Member>,
) {}

async findMembers() {
findMembers() {
Copy link
Member

Choose a reason for hiding this comment

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

async를 빼신 이유가 있으실까요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

await을 안써서 뺐습니다!

@@ -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';
Copy link
Member

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';
Copy link
Member

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: [],
Copy link
Member

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(' ', '');
Copy link
Member

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.

검색 효율성을 위해 공백을 제거한 문자열 매칭으로 탐색하기 때문에 검색어에서도 공백을 제거했습니다.


getLiveListWithKeyword(keyword) {
const currentLiveList = this.liveService.getLiveList(0);
const filteredLiveList = currentLiveList.reduce((list, live) => {
Copy link
Member

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);
Copy link
Member

Choose a reason for hiding this comment

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

아까 개발일지를 봤었는데, kmp 알고리즘과 정규표현식의 비교를 통해 정규표현식으로 결정하셨네요!
비교까지 👍🏻👍🏻 좋습니다!

Copy link
Collaborator Author

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를 적용하도록
변경하였습니다.
@JYKIM317 JYKIM317 merged commit 0131823 into dev Dec 2, 2024
1 check failed
@JYKIM317 JYKIM317 deleted the feature/#search branch December 4, 2024 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
be 🐿️ 백엔드 feature ✨ 기능 개발
Projects
None yet
Development

Successfully merging this pull request may close these issues.

검색 기능
2 participants