Michal
Michal
CCConvex Community
Created by Michal on 10/14/2024 in #support-community
Don't see db results after mutation, but only after the action is done running.
wow, so i just fixed it I think by writing code for something else with changing handleBatchEnhance function, and returning list of resources instead of list of rows with resources. It doesn't make sense to me to be honest. I will try to revert this code tomorrow and see what was wrong to hopefully give you more insight.
9 replies
CCConvex Community
Created by Michal on 10/14/2024 in #support-community
Don't see db results after mutation, but only after the action is done running.
@ballingt Yeah queries do not update. So i want to see updated data on frontend after every batch which calls mutation, but now i see updates on frontend after all batches are done running.
9 replies
CCConvex Community
Created by Michal on 10/14/2024 in #support-community
Don't see db results after mutation, but only after the action is done running.
handler: async (ctx, args) => { try { await ctx.runMutation(internal.files.updateFileRecord, { fileId: args.fileId, headers: [ ...args.headers, getHeaderColumnNameFromActionType(args.actionType), ], actionType: args.actionType, actionValue: true, }); // Fetch the current rows from the database const file = await ctx.runQuery(internal.files.getFileInternal, { fileId: args.fileId, }); if (!file) throw new Error("File not found"); let currentRows = file.rows || []; for (let i = 0; i < args.batches.length; i++) { const batch = args.batches[i]; const updatedRows = await handleBatchEnhance({ batch, resourceColumnIndex: args.resourceColumnIndex, actionType: args.actionType, userId: args.userId, profileSummarizationHeaderIndex: args.profileSummarizationHeaderIndex, companyInfoHeaderIndex: args.companyInfoHeaderIndex, offering: args.offering, }); // Calculate the start index for the current batch const startIndex = i * BATCH_SIZE; // Update the current rows with the updated rows for the current batch currentRows = [ ...currentRows.slice(0, startIndex), ...updatedRows, ...currentRows.slice(startIndex + updatedRows.length), ]; console.log("updating data with updatedRows: ", updatedRows); // Update the database with the new current rows await ctx.runMutation(internal.files.updateFileRecord, { fileId: args.fileId, newRows: currentRows, }); } } catch (error) { console.log(error); } finally { await ctx.runMutation(internal.files.updateFileRecordActionRunning, { fileId: args.fileId, actionType: args.actionType, value: false, }); } }, });`
9 replies
CCConvex Community
Created by Michal on 10/14/2024 in #support-community
Don't see db results after mutation, but only after the action is done running.
`export const handleBatches = internalAction({ args: { headers: v.array(v.string()), batches: v.array(v.array(v.array(v.string()))), resourceColumnIndex: v.number(), fileId: v.id("files"), actionType: ActionType, userId: v.optional(v.string()), profileSummarizationHeaderIndex: v.optional(v.number()), companyInfoHeaderIndex: v.optional(v.number()), offering: v.optional(v.string()), },
9 replies
CCConvex Community
Created by Michal on 10/13/2024 in #support-community
Problem with internalAction
thank you very much, somehow i haven't come across this runAction method before
5 replies