Skip to content

Commit

Permalink
Feature: PR Size to Time dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexSim93 committed Nov 8, 2024
1 parent 9f4951c commit 4d76423
Show file tree
Hide file tree
Showing 7 changed files with 324 additions and 29 deletions.
110 changes: 104 additions & 6 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": "4.1.0",
"version": "4.2.0",
"description": "Generates detailed PR analytics reports within GitHub, focusing on review efficiency and team performance.",
"main": "build/index.js",
"scripts": {
Expand Down
23 changes: 23 additions & 0 deletions src/converters/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,29 @@ export type Collection = {
discussions?: Discussion;
discussionsTypes?: DiscussionType;
prSizes?: string[];
sizes?: Record<
string,
{
timeToApprove: number[];
timeToReview: number[];
timeToMerge: number[];
percentile: {
timeToApprove?: number;
timeToReview?: number;
timeToMerge?: number;
};
average: {
timeToApprove?: number;
timeToReview?: number;
timeToMerge?: number;
};
median: {
timeToApprove?: number;
timeToReview?: number;
timeToMerge?: number;
};
}
>;
reviewsConductedSize?: PullRequestSize[];
pullRequestsInfo?: PullRequestTimelineInfo[];
};
24 changes: 24 additions & 0 deletions src/converters/utils/preparePullRequestStats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,30 @@ export const preparePullRequestStats = (collection: Collection) => {
collection.timeToMerge?.map((el) => el / 60),
mergeIntervals
),
sizes: Object.entries(collection?.sizes || {}).reduce(
(acc, el) => ({
...acc,
[el[0]]: {
...acc[el[0]],
percentile: {
timeToReview: calcPercentileValue(acc[el[0]]?.timeToReview),
timeToApprove: calcPercentileValue(acc[el[0]]?.timeToApprove),
timeToMerge: calcPercentileValue(acc[el[0]]?.timeToMerge),
},
median: {
timeToReview: calcMedianValue(acc[el[0]]?.timeToReview),
timeToApprove: calcMedianValue(acc[el[0]]?.timeToApprove),
timeToMerge: calcMedianValue(acc[el[0]]?.timeToMerge),
},
average: {
timeToReview: calcAverageValue(acc[el[0]]?.timeToReview),
timeToApprove: calcAverageValue(acc[el[0]]?.timeToApprove),
timeToMerge: calcAverageValue(acc[el[0]]?.timeToMerge),
},
},
}),
collection?.sizes || {}
),
median: {
timeToReview: calcMedianValue(collection.timeToReview),
timeToApprove: calcMedianValue(collection.timeToApprove),
Expand Down
103 changes: 87 additions & 16 deletions src/converters/utils/preparePullRequestTimeline.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { getMultipleValuesInput, getValueAsIs } from "../../common/utils";
import { makeComplexRequest } from "../../requests";
import { Collection } from "../types";
import { calcDraftTime, getApproveTime } from "./calculations";
import {
calcDraftTime,
getApproveTime,
getPullRequestSize,
} from "./calculations";
import { calcDifferenceInMinutes } from "./calculations/calcDifferenceInMinutes";

export const preparePullRequestTimeline = (
Expand Down Expand Up @@ -89,21 +93,88 @@ export const preparePullRequestTimeline = (

return {
...collection,
timeToReview: typeof timeToReview === 'number'
? [...(collection?.timeToReview || []), timeToReview]
: collection.timeToReview,
timeToApprove: typeof timeToApprove === 'number'
? [...(collection?.timeToApprove || []), timeToApprove]
: collection.timeToApprove,
timeToMerge: typeof timeToMerge === 'number'
? [...(collection?.timeToMerge || []), timeToMerge]
: collection.timeToMerge,
timeToReviewRequest: typeof timeToReviewRequest === 'number'
? [...(collection?.timeToReviewRequest || []), timeToReviewRequest]
: collection.timeToReviewRequest,
timeInDraft: typeof timeInDraft === 'number'
? [...(collection?.timeInDraft || []), timeInDraft]
: collection.timeInDraft,
timeToReview:
typeof timeToReview === "number"
? [...(collection?.timeToReview || []), timeToReview]
: collection.timeToReview,
timeToApprove:
typeof timeToApprove === "number"
? [...(collection?.timeToApprove || []), timeToApprove]
: collection.timeToApprove,
timeToMerge:
typeof timeToMerge === "number"
? [...(collection?.timeToMerge || []), timeToMerge]
: collection.timeToMerge,
timeToReviewRequest:
typeof timeToReviewRequest === "number"
? [...(collection?.timeToReviewRequest || []), timeToReviewRequest]
: collection.timeToReviewRequest,
timeInDraft:
typeof timeInDraft === "number"
? [...(collection?.timeInDraft || []), timeInDraft]
: collection.timeInDraft,
sizes: {
...(collection.sizes || {}),
[getPullRequestSize(
pullRequestInfo?.additions,
pullRequestInfo?.deletions
)]: {
...(collection.sizes?.[
getPullRequestSize(
pullRequestInfo?.additions,
pullRequestInfo?.deletions
)
] || {}),
timeToApprove: timeToApprove
? [
...(collection?.sizes?.[
getPullRequestSize(
pullRequestInfo?.additions,
pullRequestInfo?.deletions
)
]?.timeToApprove || []),
timeToApprove,
]
: collection?.sizes?.[
getPullRequestSize(
pullRequestInfo?.additions,
pullRequestInfo?.deletions
)
]?.timeToApprove,
timeToReview: timeToReview
? [
...(collection?.sizes?.[
getPullRequestSize(
pullRequestInfo?.additions,
pullRequestInfo?.deletions
)
]?.timeToReview || []),
timeToReview,
]
: collection?.sizes?.[
getPullRequestSize(
pullRequestInfo?.additions,
pullRequestInfo?.deletions
)
]?.timeToReview,
timeToMerge: timeToMerge
? [
...(collection?.sizes?.[
getPullRequestSize(
pullRequestInfo?.additions,
pullRequestInfo?.deletions
)
]?.timeToMerge || []),
timeToMerge,
]
: collection?.sizes?.[
getPullRequestSize(
pullRequestInfo?.additions,
pullRequestInfo?.deletions
)
]?.timeToMerge,
},
},
pullRequestsInfo: [
...(collection?.pullRequestsInfo || []),
{
Expand Down
Loading

0 comments on commit 4d76423

Please sign in to comment.