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

refactor : rank Api querykey factor #876

Merged
merged 5 commits into from
Jan 18, 2024

Conversation

jasper200207
Copy link
Collaborator

연관 이슈

작업 요약

Rank Api 쿼리키 포멧 통일

작업 상세 설명

  • querykey factory에 맞춰 수정하였습니다.
  • 각 api 도메인에 맞추어 rankApi 파일 대신에 다른 파일로 이동했습니다.

리뷰 요구사항

3분

@jasper200207 jasper200207 self-assigned this Jan 18, 2024
@jasper200207 jasper200207 added the Refactor 리팩토링 label Jan 18, 2024
Comment on lines 49 to 60
const useGetTodayAttendanceRank = ({ page, size = 10 }: PageAndSize) => {
const fetcher = () =>
axios
.get('/attendances/today-rank', {
params: { page, size },
})
.then(({ data }) => data);

return useQuery<TodayAttendRank>(attendanceKeys.todayAttendanceRank({ page, size }), fetcher, {
keepPreviousData: true,
});
};
Copy link
Contributor

Choose a reason for hiding this comment

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

저희 params 변수 따로 빼기로 한 거 요렇게 어떤가요?

Suggested change
const useGetTodayAttendanceRank = ({ page, size = 10 }: PageAndSize) => {
const fetcher = () =>
axios
.get('/attendances/today-rank', {
params: { page, size },
})
.then(({ data }) => data);
return useQuery<TodayAttendRank>(attendanceKeys.todayAttendanceRank({ page, size }), fetcher, {
keepPreviousData: true,
});
};
const useGetTodayAttendanceRank = ({ page, size = 10 }: PageAndSize) => {
const params = { page, size };
const fetcher = () =>
axios
.get('/attendances/today-rank', {
params,
})
.then(({ data }) => data);
return useQuery<TodayAttendRank>(attendanceKeys.todayAttendanceRank(params), fetcher, {
keepPreviousData: true,
});
};

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

반영했습니다!

- camelCase 변경
- params로 묶기
- #867
todayAttendancePoint: ['todayAttendancePoint'],
todayAttendanceInfo: ({ memberId }: { memberId: number }) => ['todayAttendanceInfo', memberId],
attendanceInfoList: ({ memberId, year }: { memberId: number; year: number }) => [
'attendanceInfoList',
memberId,
year,
],
todayAttendanceRank: (param: PageAndSize) => [...attendanceKeys.base, 'todayRank', param] as const,
Copy link
Member

Choose a reason for hiding this comment

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

params로 해야할 것 같습니당

const fetcher = () =>
axios
.get('/attendances/today-rank', {
params: { page, size },
Copy link
Contributor

Choose a reason for hiding this comment

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

여기도 이렇게 가능할 것 같습니다!

Suggested change
params: { page, size },
params,

memberList: ['member', 'memberList'] as const,
pointRank: (param: PageAndSize) => [...memberKeys.base, 'pointRank', param] as const,
Copy link
Member

Choose a reason for hiding this comment

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

이것도 params해야합니당!

const useGetPointRank = ({ page, size = 10 }: PageAndSize) => {
const params = { page, size };

const fetcher = () => axios.get('/members/point-rank', { params: { page, size } }).then(({ data }) => data);
Copy link
Contributor

Choose a reason for hiding this comment

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

여기두요!

Suggested change
const fetcher = () => axios.get('/members/point-rank', { params: { page, size } }).then(({ data }) => data);
const fetcher = () => axios.get('/members/point-rank', { params }).then(({ data }) => data);


const memberKeys = {
base: ['member'] as const,
memberList: ['member', 'memberList'] as const,
Copy link
Member

Choose a reason for hiding this comment

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

여기 base가져오면 될것같습니당!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

이 부분은 rank 관련은 아니라서 안건드리긴 했는데 겸사겸사 반영해두겠습니다!

Copy link
Contributor

@publdaze publdaze 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
Member

@pipisebastian pipisebastian 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

@publdaze publdaze left a comment

Choose a reason for hiding this comment

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

💡

@jasper200207 jasper200207 merged commit 7812466 into develop Jan 18, 2024
1 check passed
@jasper200207 jasper200207 deleted the feature/rankApi_쿼리키_포맷_통일_#867 branch January 18, 2024 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Refactor 리팩토링
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

rankApi 쿼리키 포멧 통일
3 participants