-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(reviewers): adding reviewing data
- Loading branch information
Showing
10 changed files
with
95 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
export type From<T1, T2> = T1 & T2; | ||
|
||
export abstract class Mapper<From, Result> { | ||
public abstract to(data: From[] | From, params: any): Result[] | Result; | ||
public abstract to(data: From[] | From, params?: any): Result[] | Result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { | ||
AzureDevOpsReviewApiType, | ||
AzureDevOpsVoteEnum, | ||
GithubReviewApiType, | ||
GithubVoteEnum, | ||
} from 'models/api'; | ||
import type { ReviewType } from 'models/skizzle'; | ||
import { From, Mapper } from './Mapper'; | ||
|
||
export type ReviewMapperType = From< | ||
AzureDevOpsReviewApiType, | ||
GithubReviewApiType | ||
>; | ||
|
||
export class ReviewMapper extends Mapper<ReviewMapperType, ReviewType> { | ||
public to(data: ReviewMapperType[]): ReviewType { | ||
return data.reduce((acc, curr) => { | ||
let key = curr.vote || curr.state; | ||
let result = key.toString(); | ||
|
||
switch (key) { | ||
case AzureDevOpsVoteEnum.Approved: | ||
case GithubVoteEnum.Approved: | ||
result = 'Validée'; | ||
break; | ||
case AzureDevOpsVoteEnum.ApproveWithSuggestions: | ||
result = 'Validée avec suggestion(s)'; | ||
break; | ||
case GithubVoteEnum.Comment: | ||
result = 'Commentaire(s)'; | ||
break; | ||
case AzureDevOpsVoteEnum.WaitingForAuthor: | ||
case GithubVoteEnum.Pending: | ||
result = 'En attente'; | ||
break; | ||
case AzureDevOpsVoteEnum.Rejected: | ||
result = 'Refusée'; | ||
break; | ||
case GithubVoteEnum.RequestChange: | ||
result = 'Demande de changement'; | ||
break; | ||
default: | ||
result = "Pas d'avis"; | ||
break; | ||
} | ||
|
||
if (!acc[result]) { | ||
acc[result] = 0; | ||
} | ||
|
||
acc[result] = acc[result] + 1; | ||
|
||
return acc; | ||
}, {} as ReviewType); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export type ReviewType = { | ||
approved: boolean; | ||
}; | ||
import type { Dictionary } from 'shared/utils'; | ||
|
||
export type ReviewType = Dictionary<number>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters