Skip to content

Commit

Permalink
Merge branch 'development' into feat/webpage
Browse files Browse the repository at this point in the history
  • Loading branch information
gentlementlegen committed Nov 17, 2024
2 parents 3354a5a + 9cc7c4a commit 131aae5
Show file tree
Hide file tree
Showing 21 changed files with 1,197 additions and 825 deletions.
6 changes: 3 additions & 3 deletions dist/index.js

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion src/parser/content-evaluator-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export class ContentEvaluatorModule extends BaseModule {
const currentElement = result[key];
const comments = currentElement.comments ?? [];
const specificationBody = data.self?.body;

if (specificationBody && comments.length) {
promises.push(
this._processComment(comments, specificationBody, allComments).then(
Expand Down Expand Up @@ -123,11 +124,14 @@ export class ContentEvaluatorModule extends BaseModule {
currentRelevance = relevancesByAi[currentComment.id];
}

const currentReward = this._getRewardForComment(currentComment, currentRelevance);
const currentReward = this._getRewardForComment(currentComment, currentRelevance).mul(
currentComment.score?.priority ?? 1
);

currentComment.score = {
...(currentComment.score || { multiplier: 0 }),
relevance: new Decimal(currentRelevance).toNumber(),
priority: currentComment.score?.priority ?? 1,
reward: currentReward.toNumber(),
};
}
Expand Down
32 changes: 32 additions & 0 deletions src/parser/formatting-evaluator-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { BaseModule } from "../types/module";
import { GithubCommentScore, Result, WordResult } from "../types/results";
import { typeReplacer } from "../helpers/result-replacer";
import { ContextPlugin } from "../types/plugin-input";
import { GitHubIssue } from "../github-types";

interface Multiplier {
multiplier: number;
Expand Down Expand Up @@ -67,6 +68,7 @@ export class FormattingEvaluatorModule extends BaseModule {
const { formatting, words } = this._getFormattingScore(comment);
const multiplierFactor = this._multipliers?.[comment.type] ?? { multiplier: 0 };
const formattingTotal = this._calculateFormattingTotal(formatting, words, multiplierFactor).toDecimalPlaces(2);
const priority = this._parsePriorityLabel(data.self?.labels);
const reward = (comment.score?.reward ? formattingTotal.add(comment.score.reward) : formattingTotal).toNumber();
comment.score = {
...comment.score,
Expand All @@ -75,6 +77,7 @@ export class FormattingEvaluatorModule extends BaseModule {
content: formatting,
result: Object.values(formatting).reduce((acc, curr) => acc + curr.score * curr.elementCount, 0),
},
priority: priority,
words,
multiplier: multiplierFactor.multiplier,
};
Expand Down Expand Up @@ -170,4 +173,33 @@ export class FormattingEvaluatorModule extends BaseModule {
const words = this._countWordsFromRegex(htmlElement.textContent ?? "", this._multipliers[commentType]?.wordValue);
return { formatting, words };
}

_parsePriorityLabel(labels: GitHubIssue["labels"] | undefined): number {
let taskPriorityEstimate = 0;
if (!labels) return 1;
for (const label of labels) {
let priorityLabel = "";
if (typeof label === "string") {
priorityLabel = label;
} else {
priorityLabel = label.name ?? "";
}

if (priorityLabel.startsWith("Priority:")) {
const matched = priorityLabel.match(/Priority: (\d+)/i);
if (!matched) {
return 0;
}

const urgency = matched[1];
taskPriorityEstimate = Number(urgency);
}

if (taskPriorityEstimate) {
break;
}
}

return taskPriorityEstimate;
}
}
4 changes: 3 additions & 1 deletion src/parser/github-comment-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ export class GithubCommentModule extends BaseModule {

_createIncentiveRows(sortedTasks: SortedTasks | undefined) {
const content: string[] = [];

if (!sortedTasks) {
return content.join("");
}
Expand Down Expand Up @@ -239,6 +238,7 @@ export class GithubCommentModule extends BaseModule {
</details>
</td>
<td>${commentScore.score?.relevance === undefined ? "-" : commentScore.score.relevance}</td>
<td>${commentScore.score?.priority === undefined ? "-" : commentScore.score.priority}</td>
<td>${commentScore.score?.reward === undefined ? "-" : commentScore.score.reward}</td>
</tr>`;
}
Expand Down Expand Up @@ -302,6 +302,7 @@ export class GithubCommentModule extends BaseModule {
<th>Contribution</th>
<th>Count</th>
<th>Reward</th>
</tr>
</thead>
<tbody>
Expand All @@ -317,6 +318,7 @@ export class GithubCommentModule extends BaseModule {
<th>Comment</th>
<th>Formatting</th>
<th>Relevance</th>
<th>Priority</th>
<th>Reward</th>
</tr>
</thead>
Expand Down
1 change: 1 addition & 0 deletions src/types/results.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export interface GithubCommentScore {
multiplier: number;
relevance?: number;
clarity?: number;
priority?: number;
reward: number;
};
}
Loading

0 comments on commit 131aae5

Please sign in to comment.