Skip to content

Commit

Permalink
Added agreed/disagreed result for discussions
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexSim93 committed Dec 24, 2023
1 parent f01f7ee commit 97b5caa
Show file tree
Hide file tree
Showing 8 changed files with 179 additions and 29 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@ Click the links for detailed report formats and insights.

To obtain a detailed report on the types of open discussions, it is necessary to include a specific label in the first message of each discussion, enclosed in double square brackets (`[[ ]]`). For example, use `[[Performance issue]]` to categorize a discussion as related to performance issues. The action will then provide a breakdown of discussions based on these labels, allowing for a more targeted and categorized analysis of discussion topics.

In addition, reactions of :+1: and :-1: on the initial message of a discussion will be collected and displayed in the columns for "discussions received" and "discussions conducted." These reactions help to more accurately gauge the usefulness and reception of the discussions initiated.

**Example Usage**:

- In the first comment of a pull request discussion, include a label like `[[Bug]]`, `[[Feature Request]]`, or any custom label of your choice.
Expand Down
79 changes: 66 additions & 13 deletions build/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pull-request-analytics-action",
"version": "1.8.3",
"version": "1.8.4",
"description": "Generates detailed PR analytics reports within GitHub, focusing on review efficiency and team performance.",
"main": "build/index.js",
"scripts": {
Expand Down
8 changes: 6 additions & 2 deletions src/converters/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ type PullRequestTimelineInfo = {
timeToApprove: number;
};

type Discussion = {
received?: DiscussionResult;
conducted?: DiscussionResult;
};

export type Collection = {
opened: number;
closed: number;
Expand All @@ -48,13 +53,12 @@ export type Collection = {
timeToMerge?: number[];
comments: number;
totalReviewComments: number;
discussions?: number;
reviewComments?: number;
reviewsConducted?: {
[key: string]: ReviewTypeStats;
};
commentsConducted?: number;
discussionsConducted?: number;
discussions?: Discussion;
discussionsTypes?: DiscussionType;
prSizes?: string[];
reviewsConductedSize?: PullRequestSize[];
Expand Down
93 changes: 84 additions & 9 deletions src/converters/utils/prepareDiscussions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ export const prepareDiscussions = (
total:
(collection[userLogin][key].discussionsTypes![type]?.conducted
?.total || 0) + 1,
agreed:
(collection[userLogin][key].discussionsTypes![type]?.conducted
?.agreed || 0) + (discussion.reactions?.["+1"] ? 1 : 0),
disagreed:
(collection[userLogin][key].discussionsTypes![type]?.conducted
?.disagreed || 0) + (discussion.reactions?.["-1"] ? 1 : 0),
},
};
collection[pullRequestLogin][key].discussionsTypes![type] = {
Expand All @@ -46,6 +52,12 @@ export const prepareDiscussions = (
total:
(collection[pullRequestLogin][key].discussionsTypes![type]
?.received?.total || 0) + 1,
agreed:
(collection[userLogin][key].discussionsTypes![type]?.received
?.agreed || 0) + (discussion.reactions?.["+1"] ? 1 : 0),
disagreed:
(collection[userLogin][key].discussionsTypes![type]?.received
?.disagreed || 0) + (discussion.reactions?.["-1"] ? 1 : 0),
},
};
collection.total[key].discussionsTypes![type] = {
Expand All @@ -54,11 +66,23 @@ export const prepareDiscussions = (
total:
(collection.total[key].discussionsTypes![type]?.conducted
?.total || 0) + 1,
agreed:
(collection.total[key].discussionsTypes![type]?.conducted
?.agreed || 0) + (discussion.reactions?.["+1"] ? 1 : 0),
disagreed:
(collection.total[key].discussionsTypes![type]?.conducted
?.disagreed || 0) + (discussion.reactions?.["-1"] ? 1 : 0),
},
received: {
total:
(collection.total[key].discussionsTypes![type]?.received?.total ||
0) + 1,
agreed:
(collection.total[key].discussionsTypes![type]?.received
?.agreed || 0) + (discussion.reactions?.["+1"] ? 1 : 0),
disagreed:
(collection.total[key].discussionsTypes![type]?.received
?.disagreed || 0) + (discussion.reactions?.["-1"] ? 1 : 0),
},
};
});
Expand All @@ -85,18 +109,69 @@ export const prepareDiscussions = (

discussions?.forEach((discussion) => {
const userLogin = discussion.user?.login || invalidUserLogin;
collection[userLogin][key].discussionsConducted =
(collection[userLogin][key].discussionsConducted || 0) + 1;
collection.total[key].discussionsConducted =
(collection.total[key].discussionsConducted || 0) + 1;
collection[userLogin][key].discussions = {
...collection[userLogin][key].discussions,
conducted: {
total:
(collection[userLogin][key].discussions?.conducted?.total || 0) + 1,
agreed:
(collection[userLogin][key].discussions?.conducted?.agreed || 0) +
(discussion.reactions?.["+1"] ? 1 : 0),
disagreed:
(collection[userLogin][key].discussions?.conducted?.disagreed ||
0) + (discussion.reactions?.["-1"] ? 1 : 0),
},
};
collection.total[key].discussions = {
...collection.total[key].discussions,
conducted: {
total: (collection.total[key].discussions?.conducted?.total || 0) + 1,
agreed:
(collection.total[key].discussions?.conducted?.agreed || 0) +
(discussion.reactions?.["+1"] ? 1 : 0),
disagreed:
(collection.total[key].discussions?.conducted?.disagreed || 0) +
(discussion.reactions?.["-1"] ? 1 : 0),
},
};
});

if (pullRequestLogin) {
collection[pullRequestLogin][key]["discussions"] =
(discussions?.length || 0) +
(collection[pullRequestLogin][key].discussions || 0);
collection.total[key]["discussions"] =
(discussions?.length || 0) + (collection.total[key].discussions || 0);
const agreedDiscussions = discussions?.filter(
(discussion) => discussion.reactions?.["+1"]
);
const disagreedDiscussions = discussions?.filter(
(discussion) => discussion.reactions?.["-1"]
);

collection[pullRequestLogin][key].discussions = {
...collection[pullRequestLogin][key].discussions,
received: {
total:
(collection[pullRequestLogin][key].discussions?.received?.total ||
0) + (discussions?.length || 0),
agreed:
(collection[pullRequestLogin][key].discussions?.received?.agreed ||
0) + (agreedDiscussions?.length || 0),
disagreed:
(collection[pullRequestLogin][key].discussions?.received
?.disagreed || 0) + (disagreedDiscussions?.length || 0),
},
};
collection.total[key].discussions = {
...collection.total[key].discussions,
received: {
total:
(collection.total[key].discussions?.received?.total || 0) +
(discussions?.length || 0),
agreed:
(collection.total[key].discussions?.received?.agreed || 0) +
(agreedDiscussions?.length || 0),
disagreed:
(collection.total[key].discussions?.received?.disagreed || 0) +
(disagreedDiscussions?.length || 0),
},
};
}
});
};
6 changes: 4 additions & 2 deletions src/view/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ export const totalOpenedPrsHeader = "Total opened PRs";
export const additionsDeletionsHeader = "Additions/Deletions";
export const reviewCommentsHeader = "Total comments";
export const reviewConductedHeader = "Reviews conducted";
export const discussionsHeader = "Discussions received";
export const discussionsConductedHeader = "Discussions conducted";
export const discussionsHeader =
"Agreed / Disagreed / Total discussions received";
export const discussionsConductedHeader =
"Agreed / Disagreed / Total discussions conducted";
export const commentsConductedHeader = "Comments conducted";
export const commentsReceivedHeader = "Comments received";
export const reviewTypesHeader = "Changes requested / Comments / Approvals";
Expand Down
9 changes: 8 additions & 1 deletion src/view/utils/createPullRequestQualityTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,14 @@ export const createPullRequestQualityTable = (
data["total"]?.[date]?.reviewsConducted?.[user]?.[
"CHANGES_REQUESTED"
]?.toString() || "0",
data[user]?.[date]?.discussions?.toString() || "0",
`${
data[user]?.[date]?.discussions?.received?.agreed?.toString() || "0"
} / ${
data[user]?.[date]?.discussions?.received?.disagreed?.toString() ||
"0"
} / ${
data[user]?.[date]?.discussions?.received?.total?.toString() || "0"
}`,
data[user]?.[date]?.reviewComments?.toString() || "0",
];
});
Expand Down
9 changes: 8 additions & 1 deletion src/view/utils/createReviewTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,14 @@ export const createReviewTable = (
return [
`**${user}**`,
data[user]?.[date]?.merged?.toString() || "0",
data[user]?.[date]?.discussionsConducted?.toString() || "0",
`${
data[user]?.[date]?.discussions?.conducted?.agreed?.toString() || "0"
} / ${
data[user]?.[date]?.discussions?.conducted?.disagreed?.toString() ||
"0"
} / ${
data[user]?.[date]?.discussions?.conducted?.total?.toString() || "0"
}`,
data[user]?.[date]?.commentsConducted?.toString() || "0",
`${sizes
.map(
Expand Down

0 comments on commit 97b5caa

Please sign in to comment.