Log many audit changes within a request
Opened this issue · 0 comments
htuerker commented
Problem:
CSV/Airtable data imports trigger lots of audit changes which causes timeouts due to concurrent requests. (fails at when 100+ concurrent requests with minimal setup)
Possible solution:
I'd suggest extending this endpoint to process an array of audit changes to fix failing requests.
The front-end consumer is here:
We can make requests with "audits" as an array here. The only drawback here is we have to change the current usage(only 4-5 places)
In client:
setAuditChange(
() =>
(
audits: {
type: "ADD_ROW" | "UPDATE_CELL" | "DELETE_ROW";
rowId: string;
data?: { updatedField?: string };
}[]
) =>
rowyRun({
route: runRoutes.auditChange,
body: {
rowyUser: rowyUser(currentUser!),
audits: audits.map((audit) => ({
type: audit.type,
ref: {
rowPath: tableSettings.collection,
rowId: audit.rowId,
tableId: tableSettings.id,
collectionPath: tableSettings.collection,
},
data: audit.data,
})),
},
}).catch(console.log)
);
Here we can write logs iteratively.
const { audits } = req.body;
if(!Array.isArray(audits)) {
throw new Error("400: Bad Request");
}
return Promise.all(audits.map(audit => log.write(log.entry(metadata, audit))))