Skip to content
Open
Show file tree
Hide file tree
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
12 changes: 8 additions & 4 deletions prisma/mappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ export function mapCampusArea(area: RawCampusArea): CampusArea {
case 'South':
return CampusArea.SOUTH;
default:
throw new Error(`Unknown campus area: ${area.descrshort}`);
console.warn(`Unknown campus area: ${area.descrshort}, defaulting to CENTRAL`);
return CampusArea.CENTRAL;
}
}

Expand All @@ -53,7 +54,8 @@ export function mapPaymentMethod(method: RawPayMethod): PaymentMethod {
case 'Free':
return PaymentMethod.FREE;
default:
throw new Error(`Unknown payment method: ${method.descrshort}`);
console.warn(`Unknown payment method: ${method.descrshort}, defaulting to CARD`);
return PaymentMethod.CARD;
}
}

Expand All @@ -75,7 +77,8 @@ export function mapEateryType(type: RawEateryType): EateryType {
case 'General':
return EateryType.GENERAL;
default:
throw new Error(`Unknown eatery type: ${type.descr}`);
console.warn(`Unknown eatery type: ${type.descr}, defaulting to GENERAL`);
return EateryType.GENERAL;
}
}

Expand Down Expand Up @@ -107,7 +110,8 @@ export function mapEventType(eventDescription: string): EventType {
case 'Free Food':
return EventType.GENERAL;
default:
throw new Error(`Unknown event type: ${eventDescription}`);
console.warn(`Unknown event type: ${eventDescription}, defaulting to GENERAL`);
return EventType.GENERAL;
}
}

Expand Down
13 changes: 8 additions & 5 deletions prisma/scraper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,11 +385,14 @@ async function transformEateriesConcurrently(
}

if (errors.length > 0) {
const errorMessages = errors
.map((e) => `Eatery "${e.eatery.name}": ${e.error}`)
.join('\n');
throw new Error(
`Failed to transform ${errors.length} eatery(ies):\n${errorMessages}`,
const failureRate = errors.length / rawEateries.length;
if (failureRate >= 0.5) {
throw new Error(
`Aborting: ${errors.length}/${rawEateries.length} API eateries failed to transform (${Math.round(failureRate * 100)}%)`,
);
}
console.warn(
`Skipped ${errors.length} API eatery(ies) due to transform errors`,
);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}

Expand Down