Skip to content

Commit

Permalink
feat(): adjust behavior to more often, and probably more accurately, …
Browse files Browse the repository at this point in the history
…calculate review sizes and times
  • Loading branch information
mikaelvesavuori committed Mar 14, 2023
1 parent fec64c0 commit 33a9c3d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

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,7 +1,7 @@
{
"name": "gitmetrix",
"description": "Helps you find your team-level engineering metrics",
"version": "2.1.2",
"version": "2.2.0",
"author": "Mikael Vesavuori",
"license": "MIT",
"keywords": [
Expand Down
13 changes: 3 additions & 10 deletions src/domain/services/GitHubParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,22 +105,15 @@ export class GitHubParser implements Parser {

// PR state: Open
if (prState === 'open') {
if (action === 'ready_for_review') {
results.push(this.handleReviewSize(input));
} else if (action === 'opened') {
results.push(this.resultService.produceResult({ type: 'Opened' }));
}
results.push(this.handleReviewSize(input));
if (action === 'opened') results.push(this.resultService.produceResult({ type: 'Opened' }));
}
// PR state: Closed
else if (prState === 'closed' && action === 'closed') {
if (mergeState) results.push(this.resultService.produceResult({ type: 'Merged' }));
results.push(this.resultService.produceResult({ type: 'Closed' }));
// If this is simply closed, then we have no `merged_at` time
if (
input['body']['pull_request']['merged_at'] &&
input['body']['pull_request']['review_comments'] > 0
)
results.push(this.handleReviewTime(input));
if (input['body']['pull_request']['merged_at']) results.push(this.handleReviewTime(input));
} else throw new NoPullRequestParsingMatchError();

return results.filter((result: ParsedResult | ParsedResultBasic) => result);
Expand Down
10 changes: 10 additions & 0 deletions tests/unit/domain/GitHubParser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ test.serial('It should parse a "ready for review" event', (t) => {

test.serial('It should parse a "PR opened" event', (t) => {
const expected: any = [
{
change: {
additions: 1,
changedFiles: 1,
deletions: 0
},
repo: 'SOMEORG/SOMEREPO',
timestamp: currentTime,
type: 'ReviewSize'
},
{
timestamp: currentTime,
repo: 'SOMEORG/SOMEREPO',
Expand Down

0 comments on commit 33a9c3d

Please sign in to comment.