Skip to content

Conversation

@mooninbeom
Copy link
Contributor

@mooninbeom mooninbeom commented May 22, 2025

close #368

TO-DO

  • 오늘의 인기 답변 추출 비즈니스 로직 구현
  • 오늘의 인기 답변 UI 구현
  • 답변 댓글 리스트 UI 구현
  • 답변 관련 추가된 API 연결
  • 답변 관련 추가된 액션에 따른 GA 로그 추가

상세 설명

오늘의 인기 답변 추출 비즈니스 로직 구현
AnswerRepositoryfetchPopularAnswer 라는 이름의 메소드로 만들었습니다.
구현 방식은

  1. 현재 시간 확인
  2. 현재 시간이 답변을 모으는 시간(13~18.59) 일 경우 nil 반환
  3. live question 패치
  4. 해당 질문에 대한 모든 답변 패치
  5. 답변을 순회하며 좋아요+댓글 갯수 가 최대값인 질문 구하기(같을 경우 최신순으로)
  6. 해당 답변과 질문(인기 답변 터치 액션을 위함)을 반환
  7. 만약 답변이 달려있지 않을 경우 아무것도 안나옴

오늘의 인기 답변 UI 구현
기존에 만들어놓은게 있는지 모르고 새로 만들었습니다 ㅎㅎ;;
만들어놓은게 아까워서 그냥 새로 만든 걸로 넣어놨습니다!

인기 답변

답변 모으는 기간

답변이 없을 때

API 누락된 부분

  • AnswerComment(답변에 대한 댓글) 부분에 writer generation, isLiked, isMine, isReport 가 누락되어 있습니다.
  • 기존 BoardComment의 경우 코멘트 뷰에서 게시글에 상호작용(글 삭제, 신고, 게시글에 좋아요)를 할 경우 단일 게시글을 패치해서 업데이트 하는데 답변에 경우 그런 부분이 없습니다.

@mooninbeom mooninbeom self-assigned this May 22, 2025
@mooninbeom mooninbeom added Feat 기능 구현 PR-InProgress 작업 중인 PR labels May 22, 2025
AnswerComment(
id: $0.answerCommentId,
writeId: $0.writerId,
// TODO: 5/20 문의 필요(writer generation, isLiked, isMine, isReport이 있는지 여부)
Copy link
Contributor

Choose a reason for hiding this comment

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

체크 좋슴니다!

)
}

guard let question = response.content.first else { return (nil, nil, true) }
Copy link
Contributor

Choose a reason for hiding this comment

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

요렇게 되면 가장 최근의 질문(오늘의 메인 질문)만 가져올 수 있을 것 같습니다! 이는 게시판에서 사용하는데 무리가 없을 것 같으나 답변 리스트 안에서 특정 답변의 인기 답변을 호출할 때 또한 사용할 수 있게 변경하면 어떨까 합니다!

즉, var fetchPopularAnswer: (_ questionId: Int) 요런 식으로 현재 가져와야 할 질문의 ID를 인자로 받아서 처리해주면 좋을 듯 합니다!

Copy link
Contributor

Choose a reason for hiding this comment

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

++ 오늘의 메인 질문은 전용 API가 있기 때문에 고렇게 받아오는 걸루 만들어도 될 것 같구요!

try await AnswerAPI.fetchListOfQuestion(
questionId: Int(question.questionId),
threshold: threshold,
pageSize: 30,
Copy link
Contributor

Choose a reason for hiding this comment

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

페이지 사이즈가 30이어도 전부 불러올 수 있을 것 같네요 ㅎㅎ

Copy link
Contributor

@thinkySide thinkySide left a comment

Choose a reason for hiding this comment

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

비슷한 기능들일 수 있었지만 사소하게 챙겨야할 디테일(+기획쪽으로 누락된 부분)이 많았었는데, 꼼꼼하게 잘 구현해주셔서 감사합니다! 👍 👍 👍

코멘트 남긴 오늘의 인기 답변 조회 의존성 함수 수정 관련 해서만 한번 체크 부탁드립니다!

Copy link
Contributor

@OhMyungJin OhMyungJin left a comment

Choose a reason for hiding this comment

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

인기 답변 추출 로직이 이해가 잘 되어서 좋네요!
LGTM! 수고하셨습니당

publishedDate: question.livedAt?.ISO8601ToDate(.yearMonthDateTime) ?? .now,
isAnswered: question.isAnswered,
isLived: question.questionStatus == ("LIVE")
let currentQuestion = question ?? Question(
Copy link
Contributor

Choose a reason for hiding this comment

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

question이 nil이면 메인 질문이 들어가는 군요 ㅎㅎㅎ 좋습니다!

@thinkySide thinkySide merged commit c3965d5 into develop May 22, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feat 기능 구현 PR-InProgress 작업 중인 PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] API 업데이트 기능 구현

4 participants