From 6a58676b63dcadf64e81823b2613edb26b9e9442 Mon Sep 17 00:00:00 2001 From: xxxjinn Date: Sun, 8 Sep 2024 23:21:15 +0900 Subject: [PATCH 01/15] style: edit author bar chart width (200 to 250) --- .../Statistics/AuthorBarChart/AuthorBarChart.const.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/view/src/components/Statistics/AuthorBarChart/AuthorBarChart.const.ts b/packages/view/src/components/Statistics/AuthorBarChart/AuthorBarChart.const.ts index 43f1600b..8757e750 100644 --- a/packages/view/src/components/Statistics/AuthorBarChart/AuthorBarChart.const.ts +++ b/packages/view/src/components/Statistics/AuthorBarChart/AuthorBarChart.const.ts @@ -1,5 +1,5 @@ export const DIMENSIONS = { - width: 200, + width: 250, height: 200, margins: 60, }; From 63fae823fe9df6c0383f70d57b1a6de12666d01f Mon Sep 17 00:00:00 2001 From: xxxjinn Date: Sun, 8 Sep 2024 23:21:27 +0900 Subject: [PATCH 02/15] style: edit select-box styling --- .../AuthorBarChart/AuthorBarChart.scss | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/view/src/components/Statistics/AuthorBarChart/AuthorBarChart.scss b/packages/view/src/components/Statistics/AuthorBarChart/AuthorBarChart.scss index f19886ad..be478fe2 100644 --- a/packages/view/src/components/Statistics/AuthorBarChart/AuthorBarChart.scss +++ b/packages/view/src/components/Statistics/AuthorBarChart/AuthorBarChart.scss @@ -16,20 +16,20 @@ width: 100%; text-align: right; - & .select-box { - font-size: $font-size-caption; - background: transparent; - border: 1px solid $white; - border-radius: 5px; - width: fit-content; - padding: 0 10px; + .select-box { + background-color: #212121; + border: 1px solid var(--color-white); + color: var(--color-white); height: 25px; - color: $white; - outline: none; - text-align: center; + width: 100px; + font-size: $font-size-caption; + + & .MuiSvgIcon-root { + color: var(--color-white); + } - option { - background: $gray-900; + &.Mui-focused .MuiOutlinedInput-notchedOutline { + border: none; } } } From f50d7d73259ffd63bc03af12ef897e69bda4f5f9 Mon Sep 17 00:00:00 2001 From: xxxjinn Date: Sun, 8 Sep 2024 23:22:16 +0900 Subject: [PATCH 03/15] feat: change select box from select tag to mui select --- .../AuthorBarChart/AuthorBarChart.tsx | 58 ++++++++++++++----- 1 file changed, 43 insertions(+), 15 deletions(-) diff --git a/packages/view/src/components/Statistics/AuthorBarChart/AuthorBarChart.tsx b/packages/view/src/components/Statistics/AuthorBarChart/AuthorBarChart.tsx index 29674dc4..978d288a 100644 --- a/packages/view/src/components/Statistics/AuthorBarChart/AuthorBarChart.tsx +++ b/packages/view/src/components/Statistics/AuthorBarChart/AuthorBarChart.tsx @@ -1,6 +1,8 @@ -import type { ChangeEvent, MouseEvent } from "react"; +import type { MouseEvent } from "react"; import { useRef, useEffect, useState } from "react"; import * as d3 from "d3"; +import type { SelectChangeEvent } from "@mui/material"; +import { FormControl, MenuItem, Select } from "@mui/material"; import type { ClusterNode, AuthorInfo } from "types"; import { useGlobalData } from "hooks"; @@ -207,27 +209,53 @@ const AuthorBarChart = () => { setSelectedAuthor, ]); - const handleChangeMetric = (e: ChangeEvent): void => { - setMetric(e.target.value as MetricType); + const handleChangeMetric = (event: SelectChangeEvent): void => { + setMetric(event.target.value as MetricType); }; return (

Author Bar Chart

- + +
Date: Sun, 8 Sep 2024 23:26:26 +0900 Subject: [PATCH 04/15] style: edit style branch select dropdown (add marginTop) --- packages/view/src/components/BranchSelector/BranchSelector.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/view/src/components/BranchSelector/BranchSelector.tsx b/packages/view/src/components/BranchSelector/BranchSelector.tsx index ec1999f8..a77e8088 100644 --- a/packages/view/src/components/BranchSelector/BranchSelector.tsx +++ b/packages/view/src/components/BranchSelector/BranchSelector.tsx @@ -35,6 +35,7 @@ const BranchSelector = () => { sx: { backgroundColor: "#212121", color: "white", + marginTop: "1px", "& .MuiMenuItem-root": { backgroundColor: "#212121 !important ", "&:hover": { From d16b546d494c1f8425e7ae79493f4d2c9f0cda8b Mon Sep 17 00:00:00 2001 From: xxxjinn Date: Tue, 10 Sep 2024 21:52:36 +0900 Subject: [PATCH 05/15] feat: edit branch-list fake-assets for branch name length test --- packages/view/src/fake-assets/branch-list.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/view/src/fake-assets/branch-list.json b/packages/view/src/fake-assets/branch-list.json index b8a91dc6..7fa5f31d 100644 --- a/packages/view/src/fake-assets/branch-list.json +++ b/packages/view/src/fake-assets/branch-list.json @@ -1,4 +1,4 @@ { - "branchList": ["main", "develop", "release", "origin/HEAD"], + "branchList": ["main", "develop", "release", "origin/HEAD", "test branch name for long branch names"], "head": "main" } From 7068d6eb7f46a1c9871aa65cf62d094724259613 Mon Sep 17 00:00:00 2001 From: xxxjinn Date: Tue, 10 Sep 2024 21:53:07 +0900 Subject: [PATCH 06/15] feat: add BranchSelector.const file for branch name slice length --- .../view/src/components/BranchSelector/BranchSelector.const.ts | 1 + 1 file changed, 1 insertion(+) create mode 100644 packages/view/src/components/BranchSelector/BranchSelector.const.ts diff --git a/packages/view/src/components/BranchSelector/BranchSelector.const.ts b/packages/view/src/components/BranchSelector/BranchSelector.const.ts new file mode 100644 index 00000000..a444b877 --- /dev/null +++ b/packages/view/src/components/BranchSelector/BranchSelector.const.ts @@ -0,0 +1 @@ +export const SLICE_LENGTH = 15; From 2361f2441b3f9e3ab4af94f057571349d7769aa9 Mon Sep 17 00:00:00 2001 From: xxxjinn Date: Tue, 10 Sep 2024 21:55:18 +0900 Subject: [PATCH 07/15] feat: add suffix (...) to branch name --- .../view/src/components/BranchSelector/BranchSelector.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/view/src/components/BranchSelector/BranchSelector.tsx b/packages/view/src/components/BranchSelector/BranchSelector.tsx index a77e8088..85ea4b50 100644 --- a/packages/view/src/components/BranchSelector/BranchSelector.tsx +++ b/packages/view/src/components/BranchSelector/BranchSelector.tsx @@ -8,6 +8,8 @@ import { sendFetchAnalyzedDataCommand } from "services"; import "./BranchSelector.scss"; import { useLoadingStore } from "store"; +import { SLICE_LENGTH } from "./BranchSelector.const"; + const BranchSelector = () => { const { branchList, selectedBranch, setSelectedBranch } = useGlobalData(); const { setLoading } = useLoadingStore((state) => state); @@ -53,8 +55,9 @@ const BranchSelector = () => { - {option} + {option.length <= SLICE_LENGTH ? option : `${option.slice(0, SLICE_LENGTH)}...`} ))} From 92f8b2bfc2a150cbe73f43ea205379cecc712ab2 Mon Sep 17 00:00:00 2001 From: xxxjinn Date: Wed, 11 Sep 2024 17:55:34 +0900 Subject: [PATCH 08/15] refactor(view): edit branch-list fake-assets --- packages/view/src/fake-assets/branch-list.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/view/src/fake-assets/branch-list.json b/packages/view/src/fake-assets/branch-list.json index 7fa5f31d..94dbe1d5 100644 --- a/packages/view/src/fake-assets/branch-list.json +++ b/packages/view/src/fake-assets/branch-list.json @@ -1,4 +1,4 @@ { - "branchList": ["main", "develop", "release", "origin/HEAD", "test branch name for long branch names"], + "branchList": ["main", "develop", "release", "origin/HEAD", "feature/SelectedClusterGroup"], "head": "main" } From 2c1397f7da1e308071cfcb1dd680298cb2dae4fb Mon Sep 17 00:00:00 2001 From: xxxjinn Date: Sun, 29 Sep 2024 19:05:40 +0900 Subject: [PATCH 09/15] test(view): AuthorBarChart util test - return empty data --- .../AuthorBarChart/AuthorBarChart.util.test.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 packages/view/src/components/Statistics/AuthorBarChart/AuthorBarChart.util.test.ts diff --git a/packages/view/src/components/Statistics/AuthorBarChart/AuthorBarChart.util.test.ts b/packages/view/src/components/Statistics/AuthorBarChart/AuthorBarChart.util.test.ts new file mode 100644 index 00000000..0a353a9c --- /dev/null +++ b/packages/view/src/components/Statistics/AuthorBarChart/AuthorBarChart.util.test.ts @@ -0,0 +1,11 @@ +import type { ClusterNode } from "types"; + +import { getDataByAuthor } from "./AuthorBarChart.util"; + +describe("getDataByAuthor", () => { + it("should return empty array if no data is provided", () => { + const fakeData: ClusterNode[] = []; + const result = getDataByAuthor(fakeData); + expect(result).toEqual([]); + }); +}); From 272472cb94bf52e12022263fc2da3b0c534f3a86 Mon Sep 17 00:00:00 2001 From: xxxjinn Date: Sun, 29 Sep 2024 19:06:49 +0900 Subject: [PATCH 10/15] test(view): AuthorBarChart util test- correctly provide commit information --- .../AuthorBarChart.util.test.ts | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/packages/view/src/components/Statistics/AuthorBarChart/AuthorBarChart.util.test.ts b/packages/view/src/components/Statistics/AuthorBarChart/AuthorBarChart.util.test.ts index 0a353a9c..57bec39f 100644 --- a/packages/view/src/components/Statistics/AuthorBarChart/AuthorBarChart.util.test.ts +++ b/packages/view/src/components/Statistics/AuthorBarChart/AuthorBarChart.util.test.ts @@ -1,4 +1,5 @@ import type { ClusterNode } from "types"; +import type { Commit } from "types/Commit"; import { getDataByAuthor } from "./AuthorBarChart.util"; @@ -8,4 +9,84 @@ describe("getDataByAuthor", () => { const result = getDataByAuthor(fakeData); expect(result).toEqual([]); }); + + it("should correctly aggregate commit, insertion, and deletion for authors", () => { + const fakeData: ClusterNode[] = [ + { + nodeTypeName: "CLUSTER", + commitNodeList: [ + { + nodeTypeName: "COMMIT", + commit: { + id: "1", + parentIds: ["0"], + author: { names: ["xxxjinn"] }, + committer: { names: ["xxxjinn"] }, + authorDate: "2024-01-01T00:00:00Z", + commitDate: "2024-01-01T00:00:00Z", + diffStatistics: { + insertions: 5, + deletions: 3, + }, + message: "Initial commit", + } as Commit, + seq: 1, + clusterId: 101, + }, + { + nodeTypeName: "COMMIT", + commit: { + id: "2", + parentIds: ["1"], + author: { names: ["xxxjinn"] }, + committer: { names: ["xxxjinn"] }, + authorDate: "2024-01-02T00:00:00Z", + commitDate: "2024-01-02T00:00:00Z", + diffStatistics: { + insertions: 2, + deletions: 1, + }, + message: "Second commit", + } as Commit, + seq: 2, + clusterId: 101, + }, + { + nodeTypeName: "COMMIT", + commit: { + id: "3", + parentIds: ["1"], + author: { names: ["user2"] }, + committer: { names: ["user2"] }, + authorDate: "2024-01-03T00:00:00Z", + commitDate: "2024-01-03T00:00:00Z", + diffStatistics: { + insertions: 3, + deletions: 2, + }, + message: "Third commit", + } as Commit, + seq: 3, + clusterId: 102, + }, + ], + }, + ]; + + const result = getDataByAuthor(fakeData); + expect(result).toEqual([ + { + name: "xxxjinn", + commit: 2, + insertion: 7, + deletion: 4, + }, + { + name: "user2", + commit: 1, + insertion: 3, + deletion: 2, + }, + ]); + }); }); From 8a7b01e64ff9ed50efab7218f7e5837398b7f62c Mon Sep 17 00:00:00 2001 From: xxxjinn Date: Thu, 3 Oct 2024 21:42:29 +0900 Subject: [PATCH 11/15] =?UTF-8?q?refactor(view):=20AuthorBarChart=20util?= =?UTF-8?q?=20test=20expect=EC=97=90=20type=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Statistics/AuthorBarChart/AuthorBarChart.util.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/view/src/components/Statistics/AuthorBarChart/AuthorBarChart.util.test.ts b/packages/view/src/components/Statistics/AuthorBarChart/AuthorBarChart.util.test.ts index 57bec39f..bbd97810 100644 --- a/packages/view/src/components/Statistics/AuthorBarChart/AuthorBarChart.util.test.ts +++ b/packages/view/src/components/Statistics/AuthorBarChart/AuthorBarChart.util.test.ts @@ -2,6 +2,7 @@ import type { ClusterNode } from "types"; import type { Commit } from "types/Commit"; import { getDataByAuthor } from "./AuthorBarChart.util"; +import type { AuthorDataType } from "./AuthorBarChart.type"; describe("getDataByAuthor", () => { it("should return empty array if no data is provided", () => { @@ -87,6 +88,6 @@ describe("getDataByAuthor", () => { insertion: 3, deletion: 2, }, - ]); + ] as AuthorDataType[]); }); }); From e28dd7f3e336e053995b03a16f8cf1df233fdc5a Mon Sep 17 00:00:00 2001 From: xxxjinn Date: Thu, 3 Oct 2024 22:05:29 +0900 Subject: [PATCH 12/15] test(view): AuthorBarChart util - sortDataByName test --- .../AuthorBarChart.util.test.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/packages/view/src/components/Statistics/AuthorBarChart/AuthorBarChart.util.test.ts b/packages/view/src/components/Statistics/AuthorBarChart/AuthorBarChart.util.test.ts index bbd97810..79cb28d1 100644 --- a/packages/view/src/components/Statistics/AuthorBarChart/AuthorBarChart.util.test.ts +++ b/packages/view/src/components/Statistics/AuthorBarChart/AuthorBarChart.util.test.ts @@ -1,7 +1,7 @@ import type { ClusterNode } from "types"; import type { Commit } from "types/Commit"; -import { getDataByAuthor } from "./AuthorBarChart.util"; +import { getDataByAuthor, sortDataByName } from "./AuthorBarChart.util"; import type { AuthorDataType } from "./AuthorBarChart.type"; describe("getDataByAuthor", () => { @@ -91,3 +91,20 @@ describe("getDataByAuthor", () => { ] as AuthorDataType[]); }); }); + +describe("sortDataByName", () => { + it("should return 1 when nameA is lexicographically smaller than nameB", () => { + const result = sortDataByName("apple", "banana"); + expect(result).toBe(1); + }); + + it("should return -1 when nameA is lexicographically larger than nameB", () => { + const result = sortDataByName("banana", "apple"); + expect(result).toBe(-1); + }); + + it("should return 0 when nameA is equal to nameB", () => { + const result = sortDataByName("apple", "APPLE"); + expect(result).toBe(0); + }); +}); From 5f30b9c730d55fa3d559d5aeaf7caf7239d305f0 Mon Sep 17 00:00:00 2001 From: xxxjinn Date: Thu, 3 Oct 2024 22:06:22 +0900 Subject: [PATCH 13/15] test(view): AuthorBarChart util - convertNumberFormat test --- .../AuthorBarChart.util.test.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/packages/view/src/components/Statistics/AuthorBarChart/AuthorBarChart.util.test.ts b/packages/view/src/components/Statistics/AuthorBarChart/AuthorBarChart.util.test.ts index 79cb28d1..e5db2a4d 100644 --- a/packages/view/src/components/Statistics/AuthorBarChart/AuthorBarChart.util.test.ts +++ b/packages/view/src/components/Statistics/AuthorBarChart/AuthorBarChart.util.test.ts @@ -1,7 +1,7 @@ import type { ClusterNode } from "types"; import type { Commit } from "types/Commit"; -import { getDataByAuthor, sortDataByName } from "./AuthorBarChart.util"; +import { convertNumberFormat, getDataByAuthor, sortDataByName } from "./AuthorBarChart.util"; import type { AuthorDataType } from "./AuthorBarChart.type"; describe("getDataByAuthor", () => { @@ -108,3 +108,20 @@ describe("sortDataByName", () => { expect(result).toBe(0); }); }); + +describe("convertNumberFormat", () => { + it("should return the number as a string if it's between 0 and 1", () => { + const result = convertNumberFormat(0.5); + expect(result).toBe("0.5"); + }); + + it("should format numbers greater than 1", () => { + const result = convertNumberFormat(1000); + expect(result).toBe("1k"); + }); + + it("should handle numbers less than 0 but greater than or equal to 0", () => { + const result = convertNumberFormat(0.001); + expect(result).toBe("0.001"); + }); +}); From 5274ff2300a9fd74674f1c784f72486d37a14883 Mon Sep 17 00:00:00 2001 From: xxxjinn Date: Thu, 3 Oct 2024 22:07:07 +0900 Subject: [PATCH 14/15] test(view): AuthorBarChart util - sortDataByAuthor test --- .../AuthorBarChart.util.test.ts | 114 +++++++++++++++++- 1 file changed, 112 insertions(+), 2 deletions(-) diff --git a/packages/view/src/components/Statistics/AuthorBarChart/AuthorBarChart.util.test.ts b/packages/view/src/components/Statistics/AuthorBarChart/AuthorBarChart.util.test.ts index e5db2a4d..0ec62ec0 100644 --- a/packages/view/src/components/Statistics/AuthorBarChart/AuthorBarChart.util.test.ts +++ b/packages/view/src/components/Statistics/AuthorBarChart/AuthorBarChart.util.test.ts @@ -1,7 +1,7 @@ -import type { ClusterNode } from "types"; +import type { ClusterNode, CommitNode } from "types"; import type { Commit } from "types/Commit"; -import { convertNumberFormat, getDataByAuthor, sortDataByName } from "./AuthorBarChart.util"; +import { convertNumberFormat, getDataByAuthor, sortDataByAuthor, sortDataByName } from "./AuthorBarChart.util"; import type { AuthorDataType } from "./AuthorBarChart.type"; describe("getDataByAuthor", () => { @@ -125,3 +125,113 @@ describe("convertNumberFormat", () => { expect(result).toBe("0.001"); }); }); + +describe("sortDataByAuthor", () => { + it("should filter clusters based on author names", () => { + const fakeData: ClusterNode[] = [ + { + nodeTypeName: "CLUSTER", + commitNodeList: [ + { + nodeTypeName: "COMMIT", + commit: { + id: "1", + parentIds: ["0"], + author: { names: ["author1"] }, + committer: { names: ["author1"] }, + authorDate: "2024-01-01T00:00:00Z", + commitDate: "2024-01-01T00:00:00Z", + diffStatistics: { + insertions: 5, + deletions: 3, + }, + message: "Initial commit", + } as CommitNode["commit"], + seq: 1, + clusterId: 101, + }, + { + nodeTypeName: "COMMIT", + commit: { + id: "2", + parentIds: ["1"], + author: { names: ["author2"] }, + committer: { names: ["author2"] }, + authorDate: "2024-01-02T00:00:00Z", + commitDate: "2024-01-02T00:00:00Z", + diffStatistics: { + insertions: 2, + deletions: 1, + }, + message: "Second commit", + } as CommitNode["commit"], + seq: 2, + clusterId: 101, + }, + ], + }, + ]; + + const names = ["author1"]; + const result = sortDataByAuthor(fakeData, names); + + expect(result).toEqual([ + { + nodeTypeName: "CLUSTER", + commitNodeList: [ + { + nodeTypeName: "COMMIT", + commit: { + id: "1", + parentIds: ["0"], + author: { names: ["author1"] }, + committer: { names: ["author1"] }, + authorDate: "2024-01-01T00:00:00Z", + commitDate: "2024-01-01T00:00:00Z", + diffStatistics: { + insertions: 5, + deletions: 3, + }, + message: "Initial commit", + }, + seq: 1, + clusterId: 101, + }, + ], + }, + ] as ClusterNode[]); + }); + + it("should return an empty array if no author matches", () => { + const fakeData: ClusterNode[] = [ + { + nodeTypeName: "CLUSTER", + commitNodeList: [ + { + nodeTypeName: "COMMIT", + commit: { + id: "1", + parentIds: ["0"], + author: { names: ["author1"] }, + committer: { names: ["author1"] }, + authorDate: "2024-01-01T00:00:00Z", + commitDate: "2024-01-01T00:00:00Z", + diffStatistics: { + insertions: 5, + deletions: 3, + }, + message: "Initial commit", + } as CommitNode["commit"], + seq: 1, + clusterId: 101, + }, + ], + }, + ]; + + const names = ["nonexistentAuthor"]; + const result = sortDataByAuthor(fakeData, names); + + expect(result).toEqual([]); + }); +}); From d73768fa08b8e2fd8ff3064195eabf0e5831d01f Mon Sep 17 00:00:00 2001 From: xxxjinn Date: Thu, 3 Oct 2024 22:13:24 +0900 Subject: [PATCH 15/15] test(view): AuthorBarChart util - convertNumberFormat delete tc --- .../Statistics/AuthorBarChart/AuthorBarChart.util.test.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/packages/view/src/components/Statistics/AuthorBarChart/AuthorBarChart.util.test.ts b/packages/view/src/components/Statistics/AuthorBarChart/AuthorBarChart.util.test.ts index 0ec62ec0..37f60ef7 100644 --- a/packages/view/src/components/Statistics/AuthorBarChart/AuthorBarChart.util.test.ts +++ b/packages/view/src/components/Statistics/AuthorBarChart/AuthorBarChart.util.test.ts @@ -119,11 +119,6 @@ describe("convertNumberFormat", () => { const result = convertNumberFormat(1000); expect(result).toBe("1k"); }); - - it("should handle numbers less than 0 but greater than or equal to 0", () => { - const result = convertNumberFormat(0.001); - expect(result).toBe("0.001"); - }); }); describe("sortDataByAuthor", () => {