Skip to content

Commit

Permalink
chore: avoid drilling comments unnecessarily
Browse files Browse the repository at this point in the history
  • Loading branch information
gentlementlegen authored and gentlementlegen committed Mar 24, 2024
1 parent c2f40c9 commit e960b76
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/parser/content-evaluator-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,16 @@ export class ContentEvaluatorModule implements Module {
const specificationBody = (data.self as GitHubIssue)?.body;

if (specificationBody && comments.length) {
promises.push(
this._processComment(
comments,
specificationBody,
comments.map((comment) => comment.content)
)
);
promises.push(this._processComment(comments, specificationBody));
}
}

await Promise.all(promises);
return result;
}

async _processComment(comments: GithubCommentScore[], specificationBody: string, commentsBody: string[]) {
async _processComment(comments: GithubCommentScore[], specificationBody: string) {
const commentsBody = comments.map((comment) => comment.content);
const relevance = await this._sampleRelevanceScoreResults(specificationBody, commentsBody);

if (relevance.length !== comments.length) {
Expand All @@ -51,7 +46,7 @@ export class ContentEvaluatorModule implements Module {
for (let i = 0; i < relevance.length; i++) {
const currentComment = comments[i];
const currentRelevance = relevance[i];
const currentReward = new Decimal(currentComment.score?.reward ? currentComment.score.reward : 0);
const currentReward = new Decimal(currentComment.score?.reward || 0);
currentComment.score = {
...(currentComment.score || {}),
relevance: currentRelevance.toNumber(),
Expand Down

0 comments on commit e960b76

Please sign in to comment.