Merge pull request #14097 from Budibase/fix/squash-oldrow-in-external-row-controller

Squash the oldRow prop in the external row controller
This commit is contained in:
deanhannigan 2024-07-05 11:23:31 +01:00 committed by GitHub
commit 581721caf7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 7 deletions

View File

@ -72,15 +72,23 @@ export async function patch(ctx: UserCtx<PatchRowRequest, PatchRowResponse>) {
const row = await sdk.rows.external.getRow(tableId, updatedId, { const row = await sdk.rows.external.getRow(tableId, updatedId, {
relationships: true, relationships: true,
}) })
const enrichedRow = await outputProcessing(table, row, {
squash: true, const [enrichedRow, oldRow] = await Promise.all([
preserveLinks: true, outputProcessing(table, row, {
}) squash: true,
preserveLinks: true,
}),
outputProcessing(table, beforeRow, {
squash: true,
preserveLinks: true,
}),
])
return { return {
...response, ...response,
row: enrichedRow, row: enrichedRow,
table, table,
oldRow: beforeRow, oldRow,
} }
} }

View File

@ -7,7 +7,7 @@ import { automationQueue } from "./bullboard"
import { checkTestFlag } from "../utilities/redis" import { checkTestFlag } from "../utilities/redis"
import * as utils from "./utils" import * as utils from "./utils"
import env from "../environment" import env from "../environment"
import { context, db as dbCore } from "@budibase/backend-core" import { context, logging, db as dbCore } from "@budibase/backend-core"
import { import {
Automation, Automation,
Row, Row,
@ -66,7 +66,11 @@ async function queueRelevantRowAutomations(
automationTrigger?.inputs && automationTrigger?.inputs &&
automationTrigger.inputs.tableId === event.row.tableId automationTrigger.inputs.tableId === event.row.tableId
) { ) {
await automationQueue.add({ automation, event }, JOB_OPTS) try {
await automationQueue.add({ automation, event }, JOB_OPTS)
} catch (e) {
logging.logAlert("Failed to queue automation", e)
}
} }
} }
}) })