-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
�feat(view): return Summary value and modify content data (#97)
* chore(view): Run `npm install` * feat(view): Turn data about summary and apply color visualizing * refactor(view): remove unnecessary id * refactor(view): remove unnecessary namebox and summary id * feat(view): change author profile hover action * chore(view): Run `npm install` * style(view): add color codes for same names * style(view): modify color function for more separate author
- Loading branch information
1 parent
d4a98a5
commit 9077c99
Showing
7 changed files
with
833 additions
and
322 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
packages/view/src/components/VerticalClusterList/Summary/Summary.const.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export const authorBgColorArray = [ | ||
"00ADF7", | ||
"0077AA", | ||
"4AC3F7", | ||
"0BD9E0", | ||
"33C2FF", | ||
"4BC4F9", | ||
"0089C4", | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 40 additions & 20 deletions
60
packages/view/src/components/VerticalClusterList/Summary/Summary.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 8 additions & 9 deletions
17
packages/view/src/components/VerticalClusterList/Summary/Summary.type.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,14 @@ | ||
export type Author = { | ||
id: string; | ||
name: string; | ||
export type Keyword = { | ||
keyword: string; | ||
count: number; | ||
}; | ||
|
||
export type Commit = { | ||
commitId: string; | ||
authorNames: Array<Author>; | ||
message: string; | ||
export type Summary = { | ||
authorNames: Array<Array<string>>; | ||
keywords: Array<Keyword>; | ||
}; | ||
|
||
export type Cluster = { | ||
id: string; | ||
commits: Array<Commit>; | ||
clusterId: number; | ||
summary: Summary; | ||
}; |
76 changes: 59 additions & 17 deletions
76
packages/view/src/components/VerticalClusterList/Summary/Summary.util.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,82 @@ | ||
import { nanoid } from "nanoid"; | ||
|
||
import type { GlobalProps, CommitNode } from "types"; | ||
|
||
import type { Cluster, Commit } from "./Summary.type"; | ||
import { authorBgColorArray } from "./Summary.const"; | ||
import type { Cluster } from "./Summary.type"; | ||
|
||
const colorName = [...authorBgColorArray]; | ||
|
||
export function getInitData({ data }: GlobalProps) { | ||
const clusters: Cluster[] = []; | ||
|
||
data.map((clusterNode) => { | ||
const cluster: Cluster = { | ||
id: nanoid(), | ||
commits: [], | ||
clusterId: clusterNode.commitNodeList[0].clusterId, | ||
summary: { | ||
authorNames: [], | ||
keywords: [], | ||
}, | ||
}; | ||
|
||
const commitArray: Commit[] = []; | ||
|
||
clusterNode.commitNodeList.map((commitNode: CommitNode) => { | ||
const temp = { | ||
commitId: commitNode.commit.id, | ||
authorNames: commitNode.commit.author.names.map((name) => ({ | ||
id: nanoid(), | ||
name: name.trim(), | ||
})), | ||
message: commitNode.commit.message, | ||
// set names | ||
const authorSet: Set<string> = new Set(); | ||
commitNode.commit.author.names.map((name) => { | ||
authorSet.add(name.trim()); | ||
return name.trim(); | ||
}); | ||
|
||
cluster.summary.authorNames.push(Array.from(authorSet)); | ||
|
||
// set keywords | ||
const keywordObject = { | ||
keyword: commitNode.commit.message.split(" ")[0], | ||
count: 1, | ||
}; | ||
|
||
commitArray.push(temp); | ||
const findKeywordIndex = cluster.summary.keywords.findIndex( | ||
(key) => key.keyword === commitNode.commit.message.split(" ")[0] | ||
); | ||
|
||
if (findKeywordIndex === -1) cluster.summary.keywords.push(keywordObject); | ||
else { | ||
cluster.summary.keywords[findKeywordIndex].count += 1; | ||
} | ||
|
||
cluster.commits = commitArray; | ||
cluster.summary.keywords.sort((a, b) => b.count - a.count); | ||
|
||
return temp; | ||
return commitNode; | ||
}); | ||
|
||
// remove name overlap | ||
const authorsSet = cluster.summary.authorNames.reduce( | ||
(set, authorArray) => { | ||
authorArray.forEach((author) => { | ||
set.add(author); | ||
}); | ||
return set; | ||
}, | ||
new Set() | ||
); | ||
|
||
cluster.summary.authorNames = []; | ||
|
||
cluster.summary.authorNames.push(Array.from(authorsSet) as Array<string>); | ||
|
||
clusters.push(cluster); | ||
|
||
return cluster; | ||
}); | ||
|
||
return clusters; | ||
} | ||
|
||
export function getColorValue(name: string) { | ||
let result = ""; | ||
|
||
const index = | ||
(name[0].charCodeAt(0) + name[1].charCodeAt(0)) % colorName.length; | ||
result = `#${colorName[index]}`; | ||
colorName.slice(0 + index, index + 1); | ||
|
||
return result; | ||
} |
2 changes: 1 addition & 1 deletion
2
packages/view/src/components/VerticalClusterList/Summary/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export { default as Summary } from "./Summary"; | ||
export type { Commit, Cluster, Author } from "./Summary.type"; | ||
export type { Cluster } from "./Summary.type"; |