Skip to content

Commit e37f94d

Browse files
authored
Merge pull request #763 from rakseong/main
[View] cluster 요약에서 cluster의 releaseTag를 보여주는 방식 변경
2 parents 77434a7 + 350d9f6 commit e37f94d

File tree

3 files changed

+38
-23
lines changed

3 files changed

+38
-23
lines changed

packages/view/src/components/VerticalClusterList/Summary/Summary.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { getClusterSizes } from "../ClusterGraph/ClusterGraph.util";
1515
import { CLUSTER_HEIGHT, DETAIL_HEIGHT, NODE_GAP } from "../ClusterGraph/ClusterGraph.const";
1616

1717
import { usePreLoadAuthorImg } from "./Summary.hook";
18-
import { getInitData, getClusterIds, getClusterById } from "./Summary.util";
18+
import { getInitData, getClusterIds, getClusterById, getCommitLatestTag } from "./Summary.util";
1919
import { Content } from "./Content";
2020

2121
const COLLAPSED_ROW_HEIGHT = CLUSTER_HEIGHT + NODE_GAP * 2;
@@ -88,7 +88,7 @@ const Summary = () => {
8888
));
8989
})}
9090
</div>
91-
<div>{cluster.latestReleaseTag}</div>
91+
<div>{getCommitLatestTag(cluster.clusterTags)}</div>
9292
<Content
9393
content={cluster.summary.content}
9494
clusterId={cluster.clusterId}

packages/view/src/components/VerticalClusterList/Summary/Summary.type.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export type Summary = {
1919
export type Cluster = {
2020
clusterId: number;
2121
summary: Summary;
22-
latestReleaseTag: string;
22+
clusterTags: string[];
2323
};
2424

2525
export type AuthSrcMap = Record<string, string>;

packages/view/src/components/VerticalClusterList/Summary/Summary.util.ts

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function tagToNumber(tag: string, maxLength: number): number {
3636
* @param tags
3737
* @returns
3838
*/
39-
function getCommitLatestTag(tags: string[]): string {
39+
export function getCommitLatestTag(tags: string[]): string {
4040
if (!Array.isArray(tags) || tags.length === 0) return "";
4141

4242
const validTags = tags.filter((tag) => isValidReleaseTag(tag));
@@ -66,37 +66,52 @@ export function getInitData(data: GlobalProps["data"]): Cluster[] {
6666
const clusters: Cluster[] = [];
6767

6868
data.map((clusterNode) => {
69-
const { commit: clusterFirstCommit, clusterId } = clusterNode.commitNodeList[0];
70-
const { message } = clusterFirstCommit;
69+
const { message } = clusterNode.commitNodeList[0].commit;
70+
const resultMsg = message.split("/n/n")[0];
71+
const cluster: Cluster = {
72+
clusterId: clusterNode.commitNodeList[0].clusterId,
73+
summary: {
74+
authorNames: [],
75+
content: {
76+
message: resultMsg,
77+
count: clusterNode.commitNodeList.length - 1,
78+
},
79+
},
80+
clusterTags: [],
81+
};
82+
7183
const clusterTags: string[] = [];
72-
const authorSet: Set<string> = new Set();
84+
const authorNameSet: Set<string> = new Set();
7385

7486
clusterNode.commitNodeList.forEach((commitNode: CommitNode) => {
7587
// set names
7688
commitNode.commit.author.names.forEach((name) => {
77-
authorSet.add(name.trim());
89+
authorNameSet.add(name.trim());
7890
});
7991

8092
// get releaseTags in cluster commitNodeList
81-
commitNode.commit.releaseTags?.forEach((tag) => {
82-
clusterTags.push(tag);
93+
commitNode.commit.releaseTags?.map((tag) => {
94+
if (clusterTags.indexOf(tag) === -1) {
95+
clusterTags.push(tag);
96+
}
97+
return clusterTags;
8398
});
8499
});
100+
cluster.summary.authorNames.push(Array.from(authorNameSet) as string[]);
85101

86-
// set latset release tag
87-
const latestReleaseTag = getCommitLatestTag(clusterTags);
102+
// set release tag in cluster
103+
cluster.clusterTags = clusterTags;
88104

89-
const cluster: Cluster = {
90-
clusterId: clusterId,
91-
summary: {
92-
authorNames: [Array.from(authorSet)],
93-
content: {
94-
message: message.split("/n/n")[0],
95-
count: clusterNode.commitNodeList.length - 1,
96-
},
97-
},
98-
latestReleaseTag: latestReleaseTag,
99-
};
105+
// remove name overlap
106+
const authorsSet = cluster.summary.authorNames.reduce((set, authorArray) => {
107+
authorArray.forEach((author) => {
108+
set.add(author);
109+
});
110+
return set;
111+
}, new Set());
112+
113+
cluster.summary.authorNames = [];
114+
cluster.summary.authorNames.push(Array.from(authorsSet) as string[]);
100115

101116
clusters.push(cluster);
102117
return cluster;

0 commit comments

Comments
 (0)