Skip to content

Commit df573e5

Browse files
committed
Fix for prize parsing and ignoring of non-prized issues.
1 parent 33b507f commit df573e5

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

services/IssueService.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,19 @@ function getUrlForChallengeId(challengeId) {
4040
/**
4141
* Parse the prize from issue title.
4242
* @param {Object} issue the issue
43+
* @returns {boolean} true if the prizes can be parsed; or false otherwise
4344
* @private
4445
*/
4546
function parsePrizes(issue) {
4647
const matches = issue.title.match(/(\$[0-9]+)(?=.*\])/g);
4748

4849
if (!matches || matches.length === 0) {
49-
throw new Error(`Cannot parse prize from title: ${issue.title}`);
50+
return false;
5051
}
5152

5253
issue.prizes = _.map(matches, (match) => parseInt(match.replace('$', ''), 10));
5354
issue.title = issue.title.replace(/^(\[.*\])/, '').trim();
55+
return true;
5456
}
5557

5658
/**
@@ -668,7 +670,11 @@ async function process(event) {
668670
issue.projectId = project.id;
669671

670672
// Parse prize from title
671-
parsePrizes(issue);
673+
let hasPrizes = parsePrizes(issue);
674+
// If the issue does not have prizes set, skip all processing
675+
if (!hasPrizes) {
676+
return;
677+
}
672678
const copilot = await userService.getRepositoryCopilot(event.provider, event.data.repository.full_name);
673679
event.copilot = copilot;
674680

0 commit comments

Comments
 (0)