Skip to content

Commit

Permalink
Make getting contest submissions safe
Browse files Browse the repository at this point in the history
  • Loading branch information
TimDaub committed Oct 31, 2024
1 parent 9a06d19 commit 8a30824
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/views/feed.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,16 @@ export async function getContestStories() {
return [];
}

const submissions = result.links
.map((href) => getSubmission(null, href, identityFilter))
.map((submission) => {
submission.upvoters = submission.upvoters.map(({ identity }) => identity);
return submission;
})
.sort((a, b) => b.upvotes - a.upvotes);
const submissions = [];
for (const href of result.links) {
try {
const sub = await getSubmission(null, href, identityFilter);
sub.upvoters = sub.upvoters.map(({ identity }) => identity);
submissions.push(sub);
} catch (err) {
log(`Skipping submission ${href}, err ${err.stack}`);
}
}

return submissions;
}
Expand Down

0 comments on commit 8a30824

Please sign in to comment.