Skip to content

Commit

Permalink
more error reporting on bulk
Browse files Browse the repository at this point in the history
  • Loading branch information
Pinwheeler committed Jan 28, 2025
1 parent 5339cec commit 1059acd
Showing 1 changed file with 27 additions and 14 deletions.
41 changes: 27 additions & 14 deletions app/routes/person.bulk.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ActionFunction } from "@remix-run/node";
import { Person } from "~/api/common/interfaces/parrit.interfaces";
import parritXataClient from "~/api/parritXataClient";
import Sentry from "@sentry/remix";

export interface BulkPersonUpdate {
persons: Person[];
Expand All @@ -12,21 +13,33 @@ export const action: ActionFunction = async ({ request }) => {
const xata = parritXataClient();
switch (request.method) {
case "PUT": {

const json = (await request.json()) as BulkPersonUpdate;
return await xata.transactions.run(
json.persons.map((p) => ({
update: {
table: "Persons",
id: p.id,
fields: {
project_id: p.project_id,
pairing_board_id: p.pairing_board_id,
name: p.name,
let json;
try {
json = (await request.json()) as BulkPersonUpdate;
} catch (err) {
Sentry.captureException(err);
Sentry.captureMessage("Failed to parse JSON in bulk person update");
throw err;
}
try {
return await xata.transactions.run(
json.persons.map((p) => ({
update: {
table: "Persons",
id: p.id,
fields: {
project_id: p.project_id,
pairing_board_id: p.pairing_board_id,
name: p.name,
},
},
},
}))
);
}))
);
} catch (err) {
Sentry.captureException(err);
Sentry.captureMessage("Failed to update person in bulk person update");
throw err;
}
}
default: {
console.error("no handler for method", request.method);
Expand Down

0 comments on commit 1059acd

Please sign in to comment.