Skip to content

Commit

Permalink
fix: update PR overview calculation to use active PRs in last 30 days…
Browse files Browse the repository at this point in the history
… / total PRs (#423)

Closes #418
  • Loading branch information
brandonroberts authored Sep 22, 2022
1 parent 8ed605d commit 05b48ff
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ interface PullRequestOverviewProps {
draft?: number;
churn?: number;
churnDirection?: string;
prActiveCount?: number;
}

const PullRequestOverview: React.FC<PullRequestOverviewProps> = ({ className, open, merged, closed, draft, churn, churnDirection = "down" }) => {
const PullRequestOverview: React.FC<PullRequestOverviewProps> = ({ className, open, merged, closed, draft, churn, churnDirection = "down", prActiveCount }) => {
const totalPullRequests = (!!open ? open : 0) + (!!merged ? merged : 0) + (!!closed ? closed : 0) + (!!draft ? draft : 0);
const prCount = prActiveCount || 0;
const activePrPercentage = totalPullRequests > 0 ? Math.round((prCount/totalPullRequests) * 100) : 0;

return (
<div className="flex flex-col gap-1">
Expand All @@ -28,7 +31,7 @@ const PullRequestOverview: React.FC<PullRequestOverviewProps> = ({ className, op
<div className={`
${churnDirection === "up" ? "text-light-grass-10" : "text-light-red-10"}
font-medium text-base tracking-tight`}>
{churnDirection === "up" ? <ArrowUpIcon size={14} /> : <ArrowDownIcon size={14} />}{churn || 0}%
{churnDirection === "up" ? <ArrowUpIcon size={14} /> : <ArrowDownIcon size={14} />}{activePrPercentage || 0}%
</div>
</div>

Expand Down
4 changes: 2 additions & 2 deletions components/molecules/RepoRow/repo-row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const getPrsSpam = (total: number, spam: number): number => {
};

const RepoRow = ({repo}:RepoRowProps): JSX.Element => {
const { name, owner: handle, owner_avatar: ownerAvatar, openPrsCount, closedPrsCount, draftPrsCount, mergedPrsCount, spamPrsCount, churn, churnTotalCount, churnDirection, prVelocityCount } = repo;
const { name, owner: handle, owner_avatar: ownerAvatar, openPrsCount, closedPrsCount, draftPrsCount, mergedPrsCount, spamPrsCount, churn, churnTotalCount, churnDirection, prVelocityCount, prActiveCount } = repo;
const { data: contributorData, meta: contributorMeta } = useContributionsList(repo.id, "", "updated_at");
const { data: commitsData, meta: commitMeta, isLoading: commitLoading } = useRepositoryCommits(repo.id);
const totalPrs = getTotalPrs(openPrsCount, mergedPrsCount, closedPrsCount, draftPrsCount);
Expand Down Expand Up @@ -125,7 +125,7 @@ const RepoRow = ({repo}:RepoRowProps): JSX.Element => {

{/* Column: PR Overview */}
<div className={classNames.cols.prOverview}>
<PullRequestOverview open={openPrsCount} merged={mergedPrsCount} closed={closedPrsCount} draft={draftPrsCount} churn={churnTotalCount} churnDirection={`${churnDirection}`}></PullRequestOverview>
<PullRequestOverview open={openPrsCount} merged={mergedPrsCount} closed={closedPrsCount} draft={draftPrsCount} churn={churnTotalCount} churnDirection={`${churnDirection}`} prActiveCount={prActiveCount}></PullRequestOverview>
</div>

{/* Column: PR Velocity */}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export interface RepositoriesRows {
churn?: string;
spamPrsCount?: number;
prVelocityCount?: number;
prActiveCount?: number;
prVelocity?:{
amount?: string
churn?: string
Expand Down

0 comments on commit 05b48ff

Please sign in to comment.