Skip to content

Commit

Permalink
chore: changed cap message
Browse files Browse the repository at this point in the history
  • Loading branch information
gentlementlegen committed Dec 4, 2024
1 parent d39ac33 commit 3ac7752
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/parser/github-comment-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ export class GithubCommentModule extends BaseModule {
async getBodyContent(result: Result, stripContent = false): Promise<string> {
const keysToRemove: string[] = [];
const bodyArray: (string | undefined)[] = [];
const taskReward = Object.values(result).reduce((acc, curr) => {
if (curr.task) {
return curr.task.reward * curr.task.multiplier;
}
return acc;
}, 0);

if (stripContent) {
this.context.logger.info("Stripping content due to excessive length.");
Expand All @@ -52,7 +58,7 @@ export class GithubCommentModule extends BaseModule {
for (const [key, value] of Object.entries(result)) {
// Remove result with 0 total from being displayed
if (result[key].total <= 0) continue;
result[key].evaluationCommentHtml = await this._generateHtml(key, value, true);
result[key].evaluationCommentHtml = await this._generateHtml(key, value, taskReward, true);
bodyArray.push(result[key].evaluationCommentHtml);
}
bodyArray.push(
Expand All @@ -69,7 +75,7 @@ export class GithubCommentModule extends BaseModule {
keysToRemove.push(key);
continue;
}
result[key].evaluationCommentHtml = await this._generateHtml(key, value);
result[key].evaluationCommentHtml = await this._generateHtml(key, value, taskReward);
bodyArray.push(result[key].evaluationCommentHtml);
}
// Remove evaluationCommentHtml because it is superfluous
Expand Down Expand Up @@ -255,7 +261,7 @@ export class GithubCommentModule extends BaseModule {
return content.join("");
}

async _generateHtml(username: string, result: Result[0], stripComments = false) {
async _generateHtml(username: string, result: Result[0], taskReward: number, stripComments = false) {
const sortedTasks = result.comments?.reduce<SortedTasks>(
(acc, curr) => {
if (curr.type & CommentKind.ISSUE) {
Expand All @@ -277,10 +283,10 @@ export class GithubCommentModule extends BaseModule {
this.context.config.erc20RewardToken
);

return `
> [!CAUTION]
> some caution text
const rewardsSum = result.comments?.reduce<number>((acc, curr) => acc + (curr.score?.reward ?? 0), 0) ?? 0;
const isCapped = result.total < rewardsSum;

return `
<details>
<summary>
<b>
Expand All @@ -297,13 +303,7 @@ export class GithubCommentModule extends BaseModule {
</b>
</summary>
${result.feeRate !== undefined ? `<h6>⚠️ ${new Decimal(result.feeRate).mul(100)}% fee rate has been applied. Consider using the&nbsp;<a href="https://dao.ubq.fi/dollar" target="_blank" rel="noopener">Ubiquity Dollar</a>&nbsp;for no fees.</h6>` : ""}
${result.total < (result.comments?.reduce((acc, curr) => acc + (curr.score?.reward ?? 0), 0) ?? 0) ? `<h6>ℹ️ Your rewards have been limited to the base reward of this task.</h6>` : ""}
<p>
> [!CAUTION]
> some caution text
</p>
${isCapped ? `<h6>ℹ️ Your rewards have been limited to the task price of ${taskReward} ${tokenSymbol}.</h6>` : ""}
<h6>Contributions Overview</h6>
<table>
<thead>
Expand Down

0 comments on commit 3ac7752

Please sign in to comment.