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

Be/feature/api PR #17

Merged
merged 22 commits into from Jul 5, 2021
Merged

Be/feature/api PR #17

merged 22 commits into from Jul 5, 2021

Conversation

choitree
Copy link
Collaborator

No description provided.

Comment on lines 16 to 22
@Query("SELECT `PLAYER`.`NAME` AS `NAME`, `PLAYER`.`POSITION` AS `POSITION`, `PLAYER`.`AT_BAT` AS `AT_BAT`, `PLAYER`.`HITS` AS `HITS`, `PLAYER`.`OUT` AS `OUT`, `PLAYER`.`BATTING_AVERAGE` AS `BATTING_AVERAGE`, `PLAYER`.`NUMBER_OF_PITCHES` AS `NUMBER_OF_PITCHES`, `PLAYER`.`TEAM_NAME` AS `TEAM_NAME`, `PLAYER`.`BATTING_ORDER` AS `BATTING_ORDER`, `PLAYER`.`IS_BATTING` AS `IS_BATTING` FROM `PLAYER`\n" +
"WHERE position = 'pitcher' AND team_name = :teamName")
Optional<Player> findPlayerByTeamNameAndPositionIsPitcher(String teamName);

@Query("SELECT `PLAYER`.`NAME` AS `NAME`, `PLAYER`.`POSITION` AS `POSITION`, `PLAYER`.`AT_BAT` AS `AT_BAT`, `PLAYER`.`HITS` AS `HITS`, `PLAYER`.`OUT` AS `OUT`, `PLAYER`.`BATTING_AVERAGE` AS `BATTING_AVERAGE`, `PLAYER`.`NUMBER_OF_PITCHES` AS `NUMBER_OF_PITCHES`, `PLAYER`.`TEAM_NAME` AS `TEAM_NAME`, `PLAYER`.`BATTING_ORDER` AS `BATTING_ORDER`, `PLAYER`.`IS_BATTING` AS `IS_BATTING` FROM `PLAYER`\n" +
"WHERE position = 'hitter' AND team_name = :teamName AND is_batting = false ORDER BY batting_order ASC limit 1")
Optional<Player> findPlayerByTeamNameAndPositionAndBattingIsFalseAndBattingOrder(String teamName);
Copy link
Owner

Choose a reason for hiding this comment

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

이 셀렉트문도 *로 대체 할 수 있지 않을까하는데..따로 이렇게 해주신 이유가 있어용?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

셀렉트문은 *보다는 가급적 컬럼명을 적어주는게 좋다고하더라구요~!!

Copy link
Owner

Choose a reason for hiding this comment

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

그 이유가 뭘까요? ㅎㅎ
제가 생각할땐 테이블의 컬럼을 다 불러준다는 의미에서 *가 가독성이 더 좋아보여서요

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

*을 지양하라는거는 호눅스도 몇 번 얘기해주셨는데 저도 이유는 잘 몰랐는데 구글링하니까 이런 내용이 나오네요!~~

사용하는 컬럼이 인덱스가 걸린 컬럼일경우 mysql 기준 인덱스를 이용해 컬럼의 데이터들을 조회하게됩니다.

당연히 성능상 이득이 있고요.

그런데 이런 성능상 이득 말고도 컬럼이 추가되거나 삭제될때도 명확하게 문제가 드러나지않는 경우가 있습니다.

컬럼이 삭제됐을경우 컬럼명이 명시되어있고, 실수로 그부분을 제거해주지않았다면 runtime에 에러가 발생하겠지만 * 로 퉁쳐져있으면 쿼리실행시 에러가 나지않을거고 다른부분에서 NPE가 발생할수있죠.

그럼 왜 NPE인지 이상한데서 문제를 찾고있을수도있습니다.

Copy link
Owner

Choose a reason for hiding this comment

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

제가 인덱스를 잘 모르는데 인덱스를 붙이면 찾는게 쉽다고 알고있긴 합니다. 혹시 저희 디비에 인덱스를 따로 붙여줬었나요?👀

컬럼이 삭제 됐을 경우라는 말은 무슨 말인지 잘 이해가 안가긴하는데,,
디비에서 컬럼을 삭제하면 Entity 클래스에는 필드가 남아있기 때문에 런타임에 에러가 나지 않을까요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

인덱스가 따로 붙어있지는 않아요~~ 저 설명을 보면 컬럼에 저렇게 명시를 해야지 내가 무슨 컬럼을 케어하는지 좀 더 이해하기 쉽다는 소리로 보입니다 만약 불필요한 컬럼을 제거하거나 필요한 컬럼을 추가한다고 했을 때, 그 사실을 더 인지하도록??
그런데 큐 이부분보다는 로직 부분을 집중적으로 먼저 봐주시면 좋겠습니다ㅠㅠㅠㅠ

@Override
List<BallCount> findAll();

@Query("SELECT `BALL_COUNT`.`ID` AS `ID`, `BALL_COUNT`.`BALL` AS `BALL`, `BALL_COUNT`.`GAME_ID` AS `GAME_ID`, `BALL_COUNT`.`PLAYER_NAME` AS `PLAYER_NAME` FROM `BALL_COUNT` " +
Copy link
Owner

Choose a reason for hiding this comment

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

select 문 *로 대체할 수 있지 않을까요??

Comment on lines 6 to 8
GameScoreResponseDTO gameScoreResponseDTO;
List<HalfInningGameResponseDTO> halfInningGameResponseDTOs;
List<PlayerResponseDTO> playerResponseDTOS;
Copy link
Owner

Choose a reason for hiding this comment

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

여기 접근 제어자 바꿔줘야 할거 같아요

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

오 네네!!

choitree and others added 13 commits May 11, 2021 04:57
- 전제 점수
- 회/이닝 별 전체 점수 리스트로
- 공격팀 선수 정보 리스트로
- 전체 점수
- url에 해당하는 회/이닝의 점수
- 투수 정보
- 타자 정보
- 공격팀의 점수 목록 (strike, ball, out, hit)
- hit 4개일 때 점수 추가
- 3아웃이 되기 전 모든 선수가 한바퀴 돌고 두 번째 차례일 때,
  이전 hit/out때문에 다음 차례 Hit/out이 안나오는 점 수정
- 처음에는 game테이블에 디비가 없고, 없을 때 추가되도록 수정
- 다음 턴 되기전에, hit/out 이외의 ball/strike 기록 지우기
-
- ballCount 데이터를 삭제할 수 있는 deleteMapping 추가
Feature : Game Score 로직 구현 (2차 수정)
@kyupid kyupid merged commit db58424 into backend Jul 5, 2021
@kyupid kyupid deleted the BE/feature/API branch July 5, 2021 11:52
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.

None yet

2 participants