Skip to content

Commit

Permalink
emergency fix
Browse files Browse the repository at this point in the history
  • Loading branch information
GhostOf0days committed Jan 16, 2024
1 parent 1a220a1 commit a93beb4
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions src/util/queryLocations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,19 +131,28 @@ export async function queryLocations(
}
const { locations: rawLocations } =
await IAPIResponseJoiSchema.validateAsync(data);
const validLocations = rawLocations.filter((location) => {
const { error } = ILocationAPIJoiSchema.validate(location);
if (error !== undefined) {
console.error("Validation error!", error.details);
// eslint-disable-next-line no-underscore-dangle
console.error("original obj", error._original);
// eslint-disable-next-line no-alert
alert(
`${location.name} has invalid corresponding data! Ignoring location and continuing validation`,
);
}
return error === undefined;
}) as IReadOnlyAPILocation[];

// Revert after implementing merging algo
const validLocations = rawLocations as IReadOnlyAPILocation[];
const { error } = ILocationAPIJoiSchema.validate(location);
console.log(error);


// Check for invalid location data
// const validLocations = rawLocations.filter((location) => {
// const { error } = ILocationAPIJoiSchema.validate(location);
// if (error !== undefined) {
// console.error("Validation error!", error.details);
// // eslint-disable-next-line no-underscore-dangle
// console.error("original obj", error._original);
// // eslint-disable-next-line no-alert
// console.log(
// `${location.name} has invalid corresponding data! Ignoring location and continuing validation`,
// );
// }
// return error === undefined;
// }) as IReadOnlyAPILocation[];

return validLocations.map((location) => ({
...location,
name: toTitleCase(location.name ?? "Untitled"), // Convert names to title case
Expand Down

0 comments on commit a93beb4

Please sign in to comment.