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

[FE] fix: 차트에서 0% 비율 제외 및 객관식 질문을 투표수 기준으로 내림차순 정렬 #837

Merged
merged 11 commits into from
Oct 16, 2024

Conversation

soosoo22
Copy link
Contributor

@soosoo22 soosoo22 commented Oct 12, 2024


🚀 어떤 기능을 구현했나요 ?

msw 환경에서 확인했을 때, 목 데이터에 0표인 경우를 가정하지 않고 기본적으로 1표 이상을 설정했기 때문에 0표 상황에 대한 예외 처리를 미처 하지 못하고 넘어갔습니다. 그 이후에 0표인 상황이 발생하면서, 차트에 0%가 그대로 표시되는 문제를 확인했습니다. 이를 개선하기 위해 0표일 경우를 차트에서 제외시켰습니다. 그리고 투표를 많이 받은 순서에서 적게 받은 순서로 차트를 보여주는 것이 좋을 것 같다고 판단해서 객관식 질문을 투표수 기준으로 내림차순 정렬하여 개선했습니다.

추가로 차트 비율을 소수점 첫째 짜리까지 반올림하도록 수정했고, 차트 관련 데이터를 상수 처리했습니다.

🔥 어떻게 해결했나요 ?

  • 목 데이터에 0표를 포함시키고, 차트에서 0% 비율을 제외하도록 로직을 수정했습니다.
export const GROUPED_REVIEWS_MOCK_DATA: GroupedReviews = {
  reviews: [
    {
      // ....
      votes: [
        { content: '반대 의견을 내더라도 듣는 사람이 기분 나쁘지 않게 이야기해요', count: 13 },
        { content: '팀원들의 의견을 잘 모아서 회의가 매끄럽게 진행되도록 해요', count: 0 },
        { content: '팀의 분위기를 주도해요', count: 5 },
        { content: '주장을 이야기할 때에는 합당한 근거가 뒤따라요', count: 3 },
        { content: '팀에게 필요한 것과 그렇지 않은 것을 잘 구분해요', count: 0 },
        { content: '팀 내 주어진 요구사항에 우선순위를 잘 매겨요', count: 1 },
        { content: '서로 다른 분야간의 소통도 중요하게 생각해요', count: 1 },
      ],
    },
    // ...
  ],
};
  const nonZeroReviewVotes = reviewVotes.filter((reviewVote) => reviewVote.count > 0);
  • 객관식 질문을 투표수 기준으로 내림차순 정렬하는 기능을 추가했습니다.
  groupedReviews.reviews.forEach((review) => {
    review.votes?.sort((voteA, voteB) => voteB.count - voteA.count);
  });
스크린샷 2024-10-12 오후 2 59 03

📝 어떤 부분에 집중해서 리뷰해야 할까요?

📚 참고 자료, 할 말

  • 평화로운 주말이네요. 리뷰미 여러분:)

const colors = generateGradientColors(reviewVotes.length, DOUGHNUT_COLOR.START, DOUGHNUT_COLOR.END);
const chartColors = generateGradientColors({
length: reviewVotes.length,
startHex: DOUGHNUT_COLOR.START,
Copy link
Contributor

Choose a reason for hiding this comment

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

상수의 속성은 카멜케이스로 해주세요

Copy link
Contributor

@chysis chysis left a comment

Choose a reason for hiding this comment

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

고생했어요~! 바다가 피드백 남긴 부분만 수정하면 될 것 같습니다 :)
확인의 의미로 Approve 남길게요

Copy link
Contributor

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

@BadaHertz52 BadaHertz52 left a comment

Choose a reason for hiding this comment

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

반영사항 확인했습니다!! 👍

@BadaHertz52 BadaHertz52 merged commit ff53dbe into develop Oct 16, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
4 participants