Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: multiply conv reward with priority for higher reward #176

Open
wants to merge 27 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
a1fc779
feat: multiply conv reward with priority for higher reward
ishowvel Oct 29, 2024
af40135
Merge branch 'ubiquity-os-marketplace:development' into development
ishowvel Oct 31, 2024
69ff0e4
fix: add a th to display priority and fix it being not being multiplied
ishowvel Nov 1, 2024
138fec2
Merge branch 'development' of https://github.com/ishowvel/text-conver…
ishowvel Nov 1, 2024
70519b2
chore: updated manifest.json and dist build
github-actions[bot] Nov 1, 2024
4bed152
chore: remove unused debug logs
ishowvel Nov 1, 2024
5539653
Merge branch 'development' of https://github.com/ishowvel/text-conver…
ishowvel Nov 1, 2024
2ff03e4
chore: updated manifest.json and dist build
github-actions[bot] Nov 1, 2024
4d9e168
chore: sync fork and add typings
ishowvel Nov 3, 2024
6c4c299
Merge branch 'development' of https://github.com/ishowvel/text-conver…
ishowvel Nov 3, 2024
f1e0ab4
chore: updated manifest.json and dist build
github-actions[bot] Nov 3, 2024
ca27c90
fix: properly mul priority level
ishowvel Nov 4, 2024
6ab931c
Merge branch 'development' of https://github.com/ishowvel/text-conver…
ishowvel Nov 4, 2024
76b9f3d
chore: updated manifest.json and dist build
github-actions[bot] Nov 4, 2024
e549b35
fix: fees.test.ts
ishowvel Nov 5, 2024
c09b16b
fix: rewards.test.ts and have precison upto 3 decimal places
ishowvel Nov 5, 2024
9ff121f
fix: process.issue.test.ts by changing output
ishowvel Nov 5, 2024
e0c88bb
Merge branch 'development' of https://github.com/ishowvel/text-conver…
ishowvel Nov 5, 2024
6160637
chore: updated manifest.json and dist build
github-actions[bot] Nov 5, 2024
c4327dd
fix: refactor .call to ._callee_$
ishowvel Nov 5, 2024
582fe29
chore: sync fork
ishowvel Nov 9, 2024
3205a28
Merge branch 'fork' into development
ishowvel Nov 9, 2024
789232c
chore: updated manifest.json and dist build
github-actions[bot] Nov 9, 2024
e019799
Merge remote-tracking branch 'upstream/development' into development
ishowvel Nov 11, 2024
4bc1ee6
Merge branch 'development' of https://github.com/ishowvel/text-conver…
ishowvel Nov 11, 2024
d080448
fix: import error regarding parsePriorityLabel
ishowvel Nov 11, 2024
5b71453
chore: remove precision loss
ishowvel Nov 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion 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 @@ -119,11 +120,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)
.toDecimalPlaces(3);
ishowvel marked this conversation as resolved.
Show resolved Hide resolved

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