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

Feat : classification post list get api, 폴더별 post list get api 수정, 폴더 이름 list get api 에 정렬 적용 #39

Closed
wants to merge 26 commits into from

Conversation

hye-on
Copy link
Collaborator

@hye-on hye-on commented Jul 5, 2024

PR 내용

추가 및 변경 사항

  • ai 분류 페이지 내
    • 폴더 이름 get api 에 정렬 적용, 전체 개수 추가
    • 전체 post list get api 추가 , 페이지네이션 적용
    • 폴더별 post list get api에 페이지네이션 적용 및 수정

참고

PR 중점사항

  • 전체 폴더가 따로 없다보니까 folderId를 null로 주는 것보다 totalCounts로 전체 개수 다 줬는데 의견 부탁드립니다.
  • classification 컬렉션에 userId도 없고 title도 없다보니 항상 populate아니면 aggregate를 해서 가져와야 해서 쿼리가 복잡해졌는데 검토 부탁드립니다.
    • populate하면 안에 있는 객체 (subdocuments)에 조건을 걸어도 원래 document에 적용이 안됨 (코멘트로 남겨놓을께요)

스크린샷

image

폴더별 get api

image

전체 get api

image

Marades and others added 20 commits June 29, 2024 17:29
- 링크 많은 순
- 폴더 생성순
- AIPostListResponse 수정
- 전체 post list get api, 폴더별 post list get api 페이지 네이션 적용
@github-actions github-actions bot added document 문서화 관련 작업 수정 및 생성 feature labels Jul 5, 2024
Comment on lines +64 to +83
@Patch('/posts')
@PatchAIPostDocs
async moveAllPost(
@GetUser() userId: string,
@Query('suggestionFolderId') suggestionFolderId: string,
) {
await this.classificationService.moveAllPostTosuggestionFolder(
userId,
suggestionFolderId,
);
}

@Delete('/posts/:postId')
@DeleteAIClassificationDocs
async abortClassification(
@GetUser() userId: string,
@Query('postId') postId: string,
) {
await this.classificationService.abortClassification(userId, postId);
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

이전 pr에 있는 내용..

Comment on lines +57 to +64
},
{
$match: {
'aiClassification.deletedAt': null,
'aiClassification.suggestedFolderId': suggestedFolderId,
},
},
{
Copy link
Collaborator Author

@hye-on hye-on Jul 5, 2024

Choose a reason for hiding this comment

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

image

post에서 ai_classification을 populate해서

'aiClassification.deletedAt': null,
 'aiClassification.suggestedFolderId': suggestedFolderId,

인 조건을 만족하는 post{ ai_classification } 을 가져오고 싶었는데

이 조건을 만족하지 않아도 불러와집니다. ( ai_classification이 null인 상태로 post도 가져와짐)

ex ) 내가 원하는 애 - 나중에 읽을 링크에 있으면서 deletedAt이 null이라 분류추천해줘야 하는 애

post {
 a,
 folderId : '나중에 읽을 링크',
    suggestedFolderId {
      deletedAt :null
      }
} 

원하지 않는데 불러지는 애 - (이미, 정치, 아이돌 폴더에 있는 애들도 나옴)

post {
 a,
 folderId : '정치',
 suggestedFolderId : null 
      
}

안에 있는 subdocument에 조건을 걸어도 post에 건 조건이 아니면 필터링이 안됨 ㅠ

그래서 생각한게 아래 두 방법.

  1. folderId에서 user의 나중에 읽을 링크 폴더 id를 가지고 post에 조건 추가해주기
    • 근데 그래도 똑같은 문제 있음
      • { ex) 정치, 아이돌 }에 있는 애들은 안가져올 수 있음
        but , 나중에 읽은 링크 에 있지만 x 눌러서 더이상 추천에 뜨면 안되는애들까지 불러짐
  2. 현재 방법... aggregate

혹시 더 좋은 방법 찾으면 제보 부탁 드립니다...

  • populate를 사용해서 서비스 단에서 걸러도 되기는 하는데 페이지네이션땜에 안 되었습니다...

Comment on lines 5 to 19
export class AIFolderNameListResponse {
@ApiProperty({
type: AIFolderNameServiceDto,
description: 'ai로 분류된 링크의 총 개수',
})
totalCounts: number;

@ApiProperty({
isArray: true,
})
list: AIFolderNameServiceDto[];
list: ClassificationFolderWithCount[];

constructor(data: AIFolderNameServiceDto[]) {
constructor(data: ClassificationFolderWithCount[]) {
this.totalCounts = data.reduce((sum, folder) => sum + folder.postCount, 0);
this.list = data;
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

전체 폴더 따로 안 넣고 총 개수 totalCounts로 추가

Copy link
Collaborator Author

@hye-on hye-on Jul 5, 2024

Choose a reason for hiding this comment

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

ai 분류 페이지에는 전체만 있어서 이렇게 해도 상관없지만
다른 곳은 즐겨찾기랑 나중에 읽을 링크도 있는데
(전자는 폴더도 아이디도 없어서,,)
어떻게 할꺼야?? @Marades

@hye-on hye-on self-assigned this Jul 5, 2024
@J-Hoplin
Copy link
Collaborator

J-Hoplin commented Jul 7, 2024

(/¯◡‿◡)/¯✧·˚ : *✧·˚ :

전체 폴더가 따로 없다보니까 folderId를 null로 주는 것보다 totalCounts로 전체 개수 다 줬는데 의견 부탁드립니다.

아무래도 카테고리 분류된 폴더 리스트를 가져오는거다 보니 _id는 없어도 되는게 맞는거같아~

@hye-on hye-on closed this Jul 20, 2024
@J-Hoplin J-Hoplin deleted the feature/classification-list-api branch July 20, 2024 06:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
document 문서화 관련 작업 수정 및 생성 feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants