refactor: use capture

This commit is contained in:
karishmas6
2024-10-29 03:46:13 +05:30
parent 9a851a8650
commit 12eee989a1
3 changed files with 27 additions and 20 deletions

View File

@@ -24,8 +24,18 @@ export async function updateGoogleSheet(robotId: string, runId: string) {
const plainRun = run.toJSON();
if (plainRun.status === 'success' && plainRun.serializableOutput) {
const data = plainRun.serializableOutput['item-0'] as { [key: string]: any }[];
if (plainRun.status === 'success') {
let data: { [key: string]: any }[] = [];
if (plainRun.serializableOutput && Object.keys(plainRun.serializableOutput).length > 0) {
data = plainRun.serializableOutput['item-0'] as { [key: string]: any }[];
} else if (plainRun.binaryOutput && plainRun.binaryOutput['item-0']) {
// Handle binaryOutput by setting the URL as a data entry
const binaryUrl = plainRun.binaryOutput['item-0'] as string;
// Create a placeholder object with the binary URL
data = [{ "Screenshot URL": binaryUrl }];
}
const robot = await Robot.findOne({ where: { 'recording_meta.id': robotId } });