Skip to content

Conversation

@crtEvent
Copy link
Collaborator

@crtEvent crtEvent commented Nov 17, 2023

🔑 Key Changes

  • existsByGuidAndSubscribe() where절 순서 변경하기
  • 테스트를 위한 Fixture 객체 만들기
  • Builder 어노테이션 생성자에서 선언하기
  • BlogPlatform에 gitblog 추가하기
  • Entity 레이어에 있던 enum들 Domain으로 위치 변경하기
  • 게시글 비교시 전체 목록 불러와서 메모리단에서 비교하고 DB에 본분을 덮어쓰는 방식으로 변경
  • 비동기 처리는 다음 PR에 올립니다

👩‍💻 To Reviewers

변경된 RSS 파싱 및 저장 로직 Sequence Diagram

sequenceDiagram
  participant Schedule
  participant PostCollectService
  participant RssPostParser
  participant RssItemResource
  participant PostEntity
  participant PostEntityJpaRepository

  Schedule ->> PostCollectService: collectPosts(): 10분마다 게시글 수집
  activate PostCollectService
  loop 저장된 구독 블로그 수 만큼 반복
    PostCollectService ->>+ RssPostParser: parseRssDocuments(): RSS XML 문서 파싱
    loop 파싱한 블로그 포스트 수 만큼 반복
      RssPostParser ->>+ RssItemResource: <<create>>
      RssItemResource -->>- RssPostParser: 파싱 결과 생성: RssItemResource
    end
    RssPostParser -->>- PostCollectService: 파싱 결과 리스트 생성: List<RssItemResource>
    PostCollectService ->>+ PostEntityJpaRepository: findAllBySubscribeOrderByPubDateDesc(): 저장된 게시글 목록 조회()
    PostEntityJpaRepository -->>- PostCollectService: 저장된 게시글 목록 반환: List<PostEntity>
    PostCollectService ->>+ PostCollectService: convertListToHashSet(): PostEntity 리스트를 HashMap으로 변환
    loop 파싱한 블로그 포스트 수 만큼 반복
      alt 기존 게시글에 존재하는 글일 경우
        rect rgb(255, 255, 204)
        PostCollectService ->>+ PostEntity: update(): 엔티티 업데이트
        PostEntity -->>- PostCollectService: 엔티티 업데이트 완료
        PostCollectService ->>+ PostEntityJpaRepository: save(): 게시글 업데이트
        end
      else 기존 게시글에 존재하지 않는 새로운 글일 경우
        rect rgb(255, 255, 204)
        PostCollectService ->>+ PostEntity: <<create>>
        PostEntity -->>- PostCollectService: 새로운 게시글 엔티티 생성: PostEntity
        PostCollectService ->>+ PostEntityJpaRepository: save(): 게시글 저장
        end
      end
    end
  end
  deactivate PostCollectService
Loading
  • 변경사항 1: 기존에 존재하는 게시글인지 확인하는 로직

    • 기존 방식: 게시글 하나 하나 마다 DB에 select하여 확인
    • 변경된 방식: 구독한 블로그의 게시글 목록을 한번에 불러와 메모리단에서 비교하는 방식으로 변경
    • 변경 이유: DB에 여러번 접근하는 것 보다 한번 접근해서 리스트로 불러 오는게 I/O비용이 효율적일 것으로 판단해서
  • 변경사항 2: 기존에 존재하던 게시글일 경우에도 DB에 업데이트하도록 변경

    • 기존 방식: 파싱한 게시글이 기존에 존재하던 게시글일 경우 아무 행동도 하지 않음
    • 변경된 방식: 기존에 존재하던 게시글일 경우에도 새로 파싱한 데이터로 업데이트
    • 변경 이유: 기존에 존재하던 글이여도 제목, 내용이 수정될 수 있기 때문
  • Fixture 이렇게 만드는거 맞나요?? 이게 더 쓰기 편한지는 아직 의문입니다. 제가 잘못 만든건지...

  • 🎯 쿼리 튜닝 : existsBySubscribeAndGuid() #35 ㅠㅠ 로직이 바꿔어서 테스트하지 못하게 되었다 ㅠㅠ

Related to

@crtEvent crtEvent self-assigned this Nov 17, 2023
@crtEvent crtEvent added 🧑🏻‍💻 backend 백엔드 로직에 관련된 라벨입니다. ✨ feature 기능 구현에 관련된 라벨입니다. labels Nov 17, 2023
@crtEvent crtEvent added this to the 2주차 milestone Nov 17, 2023
@crtEvent crtEvent changed the title PR #32 리뷰반영 - 게기등 파싱 로직 수정 PR #32 리뷰반영 - 게시글 파싱 로직 수정 Nov 17, 2023
@crtEvent crtEvent linked an issue Nov 19, 2023 that may be closed by this pull request
7 tasks
@crtEvent crtEvent merged commit 197d538 into sprint Nov 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🧑🏻‍💻 backend 백엔드 로직에 관련된 라벨입니다. ✨ feature 기능 구현에 관련된 라벨입니다.

Projects

Status: 🙆‍♀️ 머지 완료

Development

Successfully merging this pull request may close these issues.

#32번 피드백 반영하기

2 participants