Skip to content

Commit

Permalink
chore: testing handling for multipliers
Browse files Browse the repository at this point in the history
  • Loading branch information
Fernand authored and Fernand committed Mar 19, 2024
1 parent f2740cf commit ad0f120
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 6 deletions.
12 changes: 9 additions & 3 deletions rewards-configuration.default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ formattingEvaluator:
td: 1
hr: 1
multipliers:
issue-assignee-task:
formatting-multiplier: 0
word-value: 0
- types: [ISSUE, ISSUER, COLLABORATOR]:
formattingMultiplier: 1
wordValue: 0.2
- types: [ISSUE, ISSUER, CONTRIBUTOR]:
formattingMultiplier: 1
wordValue: 0.2
- types: [ISSUE, ASSIGNEE, CONTRIBUTOR]:
formattingMultiplier: 1
wordValue: 0.2
31 changes: 28 additions & 3 deletions src/get-activity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ import {
getPullRequestReviews,
} from "./start";

enum CommentType {
REVIEW = 0b1,
ISSUE = 0b10,
ASSIGNEE = 0b100,
ISSUER = 0b1000,
COLLABORATOR = 0b10000,
CONTRIBUTOR = 0b100000,
}

export class GetActivity {
constructor(private _issueParams: IssueParams) {}
self: Promise<GitHubIssue> | GitHubIssue | null = null;
Expand Down Expand Up @@ -62,18 +71,34 @@ export class GetActivity {
return Promise.all(promises);
}

_getTypeFromComment(
comment: GitHubIssueComment | GitHubPullRequestReviewComment,
self: GitHubPullRequest | GitHubIssue | null
) {
let ret = 0;
ret |= "pull_request_review_id" in comment ? CommentType.REVIEW : CommentType.ISSUE;
ret |= comment.author_association === "MEMBER" ? CommentType.COLLABORATOR : 0;
ret |= comment.author_association === "CONTRIBUTOR" ? CommentType.CONTRIBUTOR : 0;
ret |= comment.user?.id === self?.user?.id ? CommentType.ISSUER : 0;
ret |= comment.user?.id === self?.assignee?.id ? CommentType.ASSIGNEE : 0;
return ret;
}

get allComments() {
const comments: Array<(GitHubIssueComment | GitHubPullRequestReviewComment) & { type: string }> = (
const comments: Array<(GitHubIssueComment | GitHubPullRequestReviewComment) & { type: CommentType }> = (
this.comments as GitHubIssueComment[]
).map((comment) => ({
...comment,
type: "ISSUE_ASSIGNEE_TASK",
type: this._getTypeFromComment(comment, this.self as GitHubIssue),
}));
if (this.linkedReviews) {
for (const linkedReview of this.linkedReviews as Review[]) {
if (linkedReview.reviewComments) {
for (const reviewComment of linkedReview.reviewComments as GitHubPullRequestReviewComment[]) {
comments.push({ ...reviewComment, type: "REVIEW_ASSIGNEE_TASK" });
comments.push({
...reviewComment,
type: this._getTypeFromComment(reviewComment, linkedReview.self as GitHubPullRequest),
});
}
}
}
Expand Down

0 comments on commit ad0f120

Please sign in to comment.