Skip to content

Conversation

@Jxxunnn
Copy link
Contributor

@Jxxunnn Jxxunnn commented Jul 26, 2025

Related issue

Closes #807

Result

같은 날짜 복수 커밋 처리 시 TemporalFilter 통계 계산 오류 수정

  • 기존: 변수명이 서로 바뀌어 참조되어 잘못 계산됨
  • 수정: commitMap/clocMap 각각 올바른 변수 참조하도록 개선
  • 효과: 같은 날짜에 여러 커밋이 있어도 정확한 통계 표시

Work list

  • TemporalFilter.tsx 57-58줄 변수명 수정
    • commitMap.set() 에서 commitMapItem 사용하도록 변경
    • clocMap.set() 에서 clocMapItem 사용하도록 변경

Discussion

버그 상세 분석

  • 발생 조건: 같은 날짜에 2개 이상 커밋이 있을 때만 발생 (1개일 때는 우연히 정상 동작)
  • 영향: 날짜별 커밋 개수와 코드 변경량이 비정상적으로 계산됨

문제 재현 최소 코드

const testData = [
  { commit: { commitDate: "2022-08-21T14:04:23", diffStatistics: { insertions: 444, deletions: 7 } } },
  { commit: { commitDate: "2022-08-21T13:58:42", diffStatistics: { insertions: 2, deletions: 6 } } },
  { commit: { commitDate: "2022-08-21T13:58:42", diffStatistics: { insertions: 5, deletions: 0 } } },
];

function buggyLogic(data) {
  const clocMap = new Map();
  const commitMap = new Map();
  data.forEach(({ commit }) => {
    const date = new Date(commit.commitDate).toISOString().split("T")[0];
    const cloc = commit.diffStatistics.insertions + commit.diffStatistics.deletions;
    const clocMapItem = clocMap.get(date);
    const commitMapItem = commitMap.get(date);
    commitMap.set(date, clocMapItem ? clocMapItem + 1 : 1);
    clocMap.set(date, commitMapItem ? commitMapItem + cloc : cloc);
  });
  return { clocMap, commitMap };
}

const { clocMap, commitMap } = buggyLogic(testData);
console.log(clocMap.get("2022-08-21")); // 출력 3 (❌ 기대: 464)
console.log(commitMap.get("2022-08-21")); // 출력 464 (❌ 기대: 3)

@Jxxunnn Jxxunnn self-assigned this Jul 26, 2025
@Jxxunnn Jxxunnn requested a review from a team as a code owner July 26, 2025 06:18
@Jxxunnn Jxxunnn added the bug Something isn't working label Jul 26, 2025
@Jxxunnn Jxxunnn changed the title fix(view): 날짜별 커밋 및 코드 변경량 계산 오류 수정 [view] 날짜별 커밋 및 코드 변경량 계산 오류 수정 Jul 26, 2025
Copy link
Contributor

@SingTheCode SingTheCode left a comment

Choose a reason for hiding this comment

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

고생하셨습니다 ㅎㅎ

Comment on lines +57 to +58
commitMap.set(formattedDate, commitMapItem ? commitMapItem + 1 : 1);
clocMap.set(formattedDate, clocMapItem ? clocMapItem + clocValue : clocValue);
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

@ytaek ytaek left a comment

Choose a reason for hiding this comment

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

간단하지만, critical 한 오류였네요!! LGTM 입니다!!

@Jxxunnn Jxxunnn merged commit 1416267 into githru:main Jul 30, 2025
2 checks passed
@Jxxunnn Jxxunnn deleted the fix/807 branch July 30, 2025 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ✨ view

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[fix]: 시간대별 커밋 수와 코드 변경량 차트 데이터 오류

3 participants