Skip to content

[feat] 블로그 조회수 기능 추가 및 중복 증가 방지 / #99#100

Open
JayongLee wants to merge 11 commits intodevfrom
feat/#99
Open

[feat] 블로그 조회수 기능 추가 및 중복 증가 방지 / #99#100
JayongLee wants to merge 11 commits intodevfrom
feat/#99

Conversation

@JayongLee
Copy link
Member

@JayongLee JayongLee commented Oct 25, 2025

PULL REQUESTS ❤️‍🔥

이슈 번호 📌

작업 내용 📋

  • Blog 조회수 필드 추가
  • Blog 조회수 증가 로직 작성
    -> @Modifying 애노테이션 사용 (SQL의 원자성을 이용한 동시성 완화)
  • Cookie를 이용한 조회수 중복 증가 방지

스크린샷 (선택) 📸

기타 🔥

체크리스트 ✅

  • 코드가 정상적으로 컴파일되나요?
  • merge할 브랜치의 위치를 확인했나요?
  • 로컬에서 테스트 하셨나요?

@JayongLee JayongLee self-assigned this Oct 25, 2025
@JayongLee JayongLee linked an issue Oct 25, 2025 that may be closed by this pull request
3 tasks
@gemini-code-assist
Copy link

Summary of Changes

Hello @JayongLee, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

이 PR은 블로그 게시물의 조회수 기능을 도입하고, 사용자가 동일한 게시물을 여러 번 조회해도 조회수가 중복으로 증가하지 않도록 쿠키 기반의 방지 로직을 구현합니다. 이를 통해 블로그 게시물의 인기도를 정확하게 측정하고, 사용자 경험을 개선하는 데 기여합니다.

Highlights

  • 블로그 조회수 기능 추가: Blog 엔티티에 'viewCount' 필드를 추가하고, 블로그 게시물 조회 시 해당 필드를 증가시키는 로직을 구현했습니다.
  • 조회수 중복 증가 방지: 사용자가 동일한 블로그 게시물을 하루에 한 번만 조회수로 기록되도록 쿠키를 이용한 중복 증가 방지 로직을 추가했습니다.
  • @Modifying을 이용한 동시성 완화: 조회수 증가 시 @Modifying 어노테이션을 사용하여 SQL의 원자성을 활용함으로써 동시성 문제를 완화했습니다.
  • DTO 및 Repository 업데이트: BlogBasicInfoDto와 BlogDto에 'viewCount' 필드를 추가하고, BlogRepository에 조회수 증가 및 태그 페치 쿼리를 추가했습니다.
  • CookieUtils 유틸리티 클래스 도입: 쿠키 생성, 조회, 업데이트 등 쿠키 관련 작업을 처리하는 전용 유틸리티 클래스를 추가하여 코드의 재사용성과 관리 용이성을 높였습니다.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

블로그 조회수 기능 추가와 중복 증가 방지 로직을 구현한 PR 잘 보았습니다. 전반적으로 기능 구현은 잘 되었으나, 몇 가지 개선할 점이 보입니다. 특히 쿠키를 이용한 중복 조회 방지 로직에서 발생할 수 있는 버그와, 페이징 처리 시 발생할 수 있는 성능 저하 문제가 있습니다. 아래에 자세한 리뷰를 남겼으니 확인 부탁드립니다.

@JayongLee
Copy link
Member Author

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a view count feature for blog posts, including logic to prevent duplicate view increases using cookies. The changes involve adding a viewCount field to the Blog entity and related DTOs, updating the BlogRepository with a method to increment the view count, and implementing cookie-based logic in the BlogService to track and prevent duplicate views. The code appears well-structured, but there are potential issues with cookie handling and data consistency that need to be addressed.

@JayongLee
Copy link
Member Author

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

블로그 조회수 기능 추가와 중복 증가 방지 로직을 구현하신 것을 확인했습니다. 쿠키를 이용한 중복 조회 방지, @Modifying 애노테이션을 사용한 효율적인 DB 업데이트, 그리고 페이지네이션 성능 개선을 위한 2단계 조회 로직 등 좋은 시도들이 많이 보입니다. 다만, 코드의 유지보수성과 가독성을 높이기 위해 몇 가지 개선할 점을 제안드립니다. 컨트롤러의 역할을 더 가볍게 하고, 서비스 계층에서 비즈니스 로직을 더 많이 책임지도록 구조를 개선하는 것을 고려해보시면 좋겠습니다. 또한, 불필요한 DB 조회나 디버그용 코드가 남아있는 부분을 수정하면 더 완성도 높은 코드가 될 것입니다.

@JayongLee
Copy link
Member Author

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

블로그 조회수 기능 추가와 중복 증가 방지 로직 구현을 잘 마치셨습니다. 쿠키를 이용한 중복 조회 방지 아이디어가 좋고, 동시성 문제를 완화하기 위해 @Modifying 애노테이션을 사용한 점도 인상 깊습니다.

다만, 몇 가지 개선할 점이 보입니다.

  1. BlogRepositoryincreaseViewCount 메서드 반환 타입이 잘못 지정되어 있어 런타임 오류가 발생할 수 있습니다.
  2. 조회수 증가 로직이 BlogController, BlogService, ViewCountService에 분산되어 있어 구조가 복잡하고 이해하기 어렵습니다. 이를 ViewCountService로 통합하여 캡슐화하면 더 좋을 것 같습니다.
  3. BlogService에서 불필요한 데이터베이스 조회가 있습니다.

자세한 내용은 각 파일의 코드 리뷰에 남겨두었습니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feat] 블로그 조회수 기능 추가

1 participant