Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions scripts/update-topgear-reviewers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,15 @@ async function fetchDefaultReviewers(

async function backfillChallengeReviewers() {
const defaultsCache = new Map<string, DefaultChallengeReviewer[]>();

const taskTypes = await prisma.challengeType.findMany({
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ maintainability]
Consider adding error handling for the prisma.challengeType.findMany call to handle cases where the database query might fail. This will improve the robustness of the script.

where: {
name: { equals: 'Task', mode: 'insensitive' },
},
select: { id: true },
});
const taskTypeIds = new Set(taskTypes.map((type) => type.id));

const challenges = await prisma.challenge.findMany({
where: {
status: ChallengeStatusEnum.ACTIVE,
Expand Down Expand Up @@ -148,6 +157,13 @@ async function backfillChallengeReviewers() {
continue;
}

if (taskTypeIds.has(challenge.typeId)) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[💡 maintainability]
The console.log statement used for skipping Task type challenges could be replaced with a logging library or mechanism that allows for different log levels (e.g., debug, info, warn, error). This would provide more control over log output and improve maintainability.

console.log(
`Skipping challenge ${challenge.id} (${challenge.name}) because it is a Task type.`,
);
continue;
}

const defaultReviewers = await fetchDefaultReviewers(
challenge.typeId,
challenge.trackId,
Expand Down