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

[#087] 모든 역량 랭크를 조회하는 기능 구현 #88

Merged
merged 21 commits into from
Apr 20, 2024

Conversation

koomin1227
Copy link
Member

이슈

체크리스트

  • 역량 랭크를 조회하는 기능 구현
  • totalPoint 도 stat 에서 같이 조회되도록 추가
  • user_id -> userId 수정
  • 공통 부분 리펙토링

고민한 내용

Repository 리펙토링

  • stat 관련 repository에서 랭크 목록을 가져오는 메서드와 개인 랭킹을 가져오는 메서드들이 모든 repository에서 중복으로 나타났다.
  • 중복된 코드를 줄이고자 findWithRank, findIndividualRank 코드를 구현한 StatRepository를 만들고 StatRepository를 상속해서 각 Repository에서 사용하게 수정하였다.
    protected repository: Repository<any>;
    private entity;
    constructor(dataSource: DataSource, req: Request, entity) {
        super(dataSource, req);
        this.repository = this.getRepository(entity);
        this.entity = entity;
    }
  • 위와 같이 생성자에 엔티티를 넣어서 각 stat 별로 돌아갈 수 있도록 하였다

@koomin1227 koomin1227 self-assigned this Apr 19, 2024
@koomin1227
Copy link
Member Author

좀 수정 한게 많긴한데 공통되는 부분은 다 statRepository로 합쳤습니다~

Copy link
Contributor

@namewhat99 namewhat99 left a comment

Choose a reason for hiding this comment

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

statRepository 에서 entity 를 받고 해당 엔티티에 따라 알고리즘 순위와 개인 랭크를 반환하게 만들어서 코드 중복을 없게 만든 점 좋습니다.

사실 이에 대해서 해당 코드들이 중복인데 서로 다른 repository 에서 처리를 해야하나 아니면 상위 클래스에서 합쳐야 하나 고민을 했습니다. 결국 귀찮음도 일부 없었다는건 부정은 못하지만,,,, 아래 글을 보고 분리를 해 놓는게 좋을 수 도 있겠다 라는 생각이 들기도 했습니다. 정답은 없지만 한번 참고하면 좋을 것 같아서 공유드립니다.

아래 글에서 6. 산발적 수정 에 관련 내용이 있습니다.

https://jaehyeon48.github.io/software-architecture/refactoring-summary-3/

@koomin1227
Copy link
Member Author

statRepository 에서 entity 를 받고 해당 엔티티에 따라 알고리즘 순위와 개인 랭크를 반환하게 만들어서 코드 중복을 없게 만든 점 좋습니다.

사실 이에 대해서 해당 코드들이 중복인데 서로 다른 repository 에서 처리를 해야하나 아니면 상위 클래스에서 합쳐야 하나 고민을 했습니다. 결국 귀찮음도 일부 없었다는건 부정은 못하지만,,,, 아래 글을 보고 분리를 해 놓는게 좋을 수 도 있겠다 라는 생각이 들기도 했습니다. 정답은 없지만 한번 참고하면 좋을 것 같아서 공유드립니다.

아래 글에서 6. 산발적 수정 에 관련 내용이 있습니다.

https://jaehyeon48.github.io/software-architecture/refactoring-summary-3/

아 저는 그런부분 까지는 고려하지는 못했네요.. 생각지 못한 것을 짚어주셔서 감사합니다..

@koomin1227 koomin1227 merged commit 3a6b0ee into develop Apr 20, 2024
1 check passed
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.

2 participants