Skip to content

Commit

Permalink
feature(view) : SummaryUtil 리팩토링(githru#723)
Browse files Browse the repository at this point in the history
  • Loading branch information
pithesun committed Sep 29, 2024
1 parent 4e85da4 commit 73e8058
Showing 1 changed file with 17 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,55 +66,37 @@ export function getInitData(data: GlobalProps["data"]): Cluster[] {
const clusters: Cluster[] = [];

data.map((clusterNode) => {
const { message } = clusterNode.commitNodeList[0].commit;
const resultMsg = message.split("/n/n")[0];
const cluster: Cluster = {
clusterId: clusterNode.commitNodeList[0].clusterId,
summary: {
authorNames: [],
content: {
message: resultMsg,
count: clusterNode.commitNodeList.length - 1,
},
},
latestReleaseTag: "",
};

const { commit: clusterFirstCommit, clusterId } = clusterNode.commitNodeList[0];
const { message } = clusterFirstCommit;
const clusterTags: string[] = [];
const authorSet: Set<string> = new Set();

clusterNode.commitNodeList.map((commitNode: CommitNode) => {
clusterNode.commitNodeList.forEach((commitNode: CommitNode) => {
// set names
const authorSet: Set<string> = new Set();
commitNode.commit.author.names.map((name) => {
commitNode.commit.author.names.forEach((name) => {
authorSet.add(name.trim());
return name.trim();
});

cluster.summary.authorNames.push(Array.from(authorSet));

// get releaseTags in cluster commitNodeList
commitNode.commit.releaseTags?.map((tag) => {
commitNode.commit.releaseTags?.forEach((tag) => {
clusterTags.push(tag);
return clusterTags;
});

return commitNode;
});

// set latset release tag
const latestReleaseTag = getCommitLatestTag(clusterTags);
cluster.latestReleaseTag = latestReleaseTag;

// 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 string[]);
const cluster: Cluster = {
clusterId: clusterId,
summary: {
authorNames: [Array.from(authorSet)],
content: {
message: message.split("/n/n")[0],
count: clusterNode.commitNodeList.length - 1,
},
},
latestReleaseTag: latestReleaseTag,
};

clusters.push(cluster);
return cluster;
Expand Down

0 comments on commit 73e8058

Please sign in to comment.