diff --git a/src/parser/github-comment-module.ts b/src/parser/github-comment-module.ts index 083cbbbf..6a5fc281 100644 --- a/src/parser/github-comment-module.ts +++ b/src/parser/github-comment-module.ts @@ -44,6 +44,12 @@ export class GithubCommentModule extends BaseModule { async getBodyContent(result: Result, stripContent = false): Promise { 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."); @@ -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( @@ -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 @@ -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( (acc, curr) => { if (curr.type & CommentKind.ISSUE) { @@ -277,10 +283,10 @@ export class GithubCommentModule extends BaseModule { this.context.config.erc20RewardToken ); - return ` -> [!CAUTION] -> some caution text + const rewardsSum = result.comments?.reduce((acc, curr) => acc + (curr.score?.reward ?? 0), 0) ?? 0; + const isCapped = result.total < rewardsSum; + return `
@@ -297,13 +303,7 @@ export class GithubCommentModule extends BaseModule { ${result.feeRate !== undefined ? `
⚠️ ${new Decimal(result.feeRate).mul(100)}% fee rate has been applied. Consider using the Ubiquity Dollar for no fees.
` : ""} - ${result.total < (result.comments?.reduce((acc, curr) => acc + (curr.score?.reward ?? 0), 0) ?? 0) ? `
ℹ️ Your rewards have been limited to the base reward of this task.
` : ""} - -

- > [!CAUTION] - > some caution text -

- + ${isCapped ? `
ℹ️ Your rewards have been limited to the task price of ${taskReward} ${tokenSymbol}.
` : ""}
Contributions Overview