From f1d0cbdaae50a5b5abcc9489661def616b6fcdc7 Mon Sep 17 00:00:00 2001 From: Rohit Date: Wed, 30 Apr 2025 19:24:38 +0530 Subject: [PATCH] feat: rm other actions logic --- public/locales/de.json | 3 +- public/locales/en.json | 3 +- public/locales/es.json | 3 +- public/locales/ja.json | 3 +- public/locales/zh.json | 3 +- server/src/api/record.ts | 2 - server/src/pgboss-worker.ts | 7 +- .../classes/Interpreter.ts | 20 +--- .../integrations/airtable.ts | 13 --- .../integrations/gsheet.ts | 11 --- .../workflow-management/scheduler/index.ts | 2 - src/components/run/InterpretationLog.tsx | 96 ------------------- src/components/run/RunContent.tsx | 43 +-------- 13 files changed, 9 insertions(+), 200 deletions(-) diff --git a/public/locales/de.json b/public/locales/de.json index 6e561220..1256be22 100644 --- a/public/locales/de.json +++ b/public/locales/de.json @@ -547,8 +547,7 @@ "view_full": "Vollständige Daten anzeigen", "items": "Elemente", "schema_title": "Text erfassen", - "list_title": "Liste erfassen", - "other_title": "Andere Daten" + "list_title": "Liste erfassen" }, "captured_screenshot": { "title": "Erfasste Screenshots", diff --git a/public/locales/en.json b/public/locales/en.json index b8d910a1..531aa2e7 100644 --- a/public/locales/en.json +++ b/public/locales/en.json @@ -568,8 +568,7 @@ "view_full": "View Full Data", "items": "items", "schema_title": "Capture Text", - "list_title": "Capture List", - "other_title": "Other Data" + "list_title": "Capture List" }, "captured_screenshot": { "title": "Captured Screenshots", diff --git a/public/locales/es.json b/public/locales/es.json index f0e2a9df..b28fc5cf 100644 --- a/public/locales/es.json +++ b/public/locales/es.json @@ -548,8 +548,7 @@ "view_full": "Ver Datos Completos", "items": "elementos", "schema_title": "Capturar Texto", - "list_title": "Capturar Lista", - "other_title": "Otros Datos" + "list_title": "Capturar Lista" }, "captured_screenshot": { "title": "Capturas de Pantalla", diff --git a/public/locales/ja.json b/public/locales/ja.json index 91021e32..52fed446 100644 --- a/public/locales/ja.json +++ b/public/locales/ja.json @@ -548,8 +548,7 @@ "view_full": "すべてのデータを表示", "items": "アイテム", "schema_title": "テキストをキャプチャ", - "list_title": "リストをキャプチャ", - "other_title": "その他のデータ" + "list_title": "リストをキャプチャ" }, "captured_screenshot": { "title": "キャプチャされたスクリーンショット", diff --git a/public/locales/zh.json b/public/locales/zh.json index 0d327743..b4512bb3 100644 --- a/public/locales/zh.json +++ b/public/locales/zh.json @@ -548,8 +548,7 @@ "view_full": "查看完整数据", "items": "项目", "schema_title": "捕获文本", - "list_title": "捕获列表", - "other_title": "其他数据" + "list_title": "捕获列表" }, "captured_screenshot": { "title": "已捕获的截图", diff --git a/server/src/api/record.ts b/server/src/api/record.ts index 39a4b3df..2d6077a9 100644 --- a/server/src/api/record.ts +++ b/server/src/api/record.ts @@ -589,7 +589,6 @@ async function executeRun(id: string, userId: string) { const categorizedOutput = { scrapeSchema: interpretationInfo.scrapeSchemaOutput || {}, scrapeList: interpretationInfo.scrapeListOutput || {}, - other: interpretationInfo.otherOutput || {} }; await destroyRemoteBrowser(plainRun.browserId, userId); @@ -603,7 +602,6 @@ async function executeRun(id: string, userId: string) { serializableOutput: { scrapeSchema: Object.values(categorizedOutput.scrapeSchema), scrapeList: Object.values(categorizedOutput.scrapeList), - other: Object.values(categorizedOutput.other), }, binaryOutput: uploadedBinaryOutput, }); diff --git a/server/src/pgboss-worker.ts b/server/src/pgboss-worker.ts index b6cb1355..d6960a05 100644 --- a/server/src/pgboss-worker.ts +++ b/server/src/pgboss-worker.ts @@ -265,8 +265,7 @@ async function processRunExecution(job: Job) { const categorizedOutput = { scrapeSchema: interpretationInfo.scrapeSchemaOutput || {}, - scrapeList: interpretationInfo.scrapeListOutput || {}, - other: interpretationInfo.otherOutput || {} + scrapeList: interpretationInfo.scrapeListOutput || {} }; await run.update({ @@ -278,7 +277,6 @@ async function processRunExecution(job: Job) { serializableOutput: { scrapeSchema: Object.values(categorizedOutput.scrapeSchema), scrapeList: Object.values(categorizedOutput.scrapeList), - other: Object.values(categorizedOutput.other), }, binaryOutput: uploadedBinaryOutput, }); @@ -482,7 +480,6 @@ async function abortRun(runId: string, userId: string): Promise { let categorizedOutput = { scrapeSchema: {}, scrapeList: {}, - other: {} }; let binaryOutput: Record = {}; @@ -496,7 +493,6 @@ async function abortRun(runId: string, userId: string): Promise { categorizedOutput = { scrapeSchema: collectDataByType(browser.interpreter.serializableDataByType.scrapeSchema || []), scrapeList: collectDataByType(browser.interpreter.serializableDataByType.scrapeList || []), - other: collectDataByType(browser.interpreter.serializableDataByType.other || []) }; } @@ -516,7 +512,6 @@ async function abortRun(runId: string, userId: string): Promise { serializableOutput: { scrapeSchema: Object.values(categorizedOutput.scrapeSchema), scrapeList: Object.values(categorizedOutput.scrapeList), - other: Object.values(categorizedOutput.other), }, binaryOutput, }); diff --git a/server/src/workflow-management/classes/Interpreter.ts b/server/src/workflow-management/classes/Interpreter.ts index f3a5698c..0481687d 100644 --- a/server/src/workflow-management/classes/Interpreter.ts +++ b/server/src/workflow-management/classes/Interpreter.ts @@ -92,11 +92,9 @@ export class WorkflowInterpreter { public serializableDataByType: { scrapeSchema: any[], scrapeList: any[], - other: any[] } = { scrapeSchema: [], scrapeList: [], - other: [] }; /** @@ -216,12 +214,7 @@ export class WorkflowInterpreter { type: 'captureList', data }); - } else { - this.socket.emit('serializableCallback', { - type: 'other', - data - }); - } + } }, binaryCallback: (data: string, mimetype: string) => { this.socket.emit('binaryCallback', { @@ -292,7 +285,6 @@ export class WorkflowInterpreter { this.serializableDataByType = { scrapeSchema: [], scrapeList: [], - other: [] }; this.binaryData = []; } @@ -342,9 +334,7 @@ export class WorkflowInterpreter { } } else if (this.currentActionType === 'scrapeList') { this.serializableDataByType.scrapeList.push(data); - } else { - this.serializableDataByType.other.push(data); - } + } this.socket.emit('serializableCallback', data); }, @@ -394,12 +384,6 @@ export class WorkflowInterpreter { ...reducedObject, } }, {}), - otherOutput: this.serializableDataByType.other.reduce((reducedObject, item, index) => { - return { - [`item-${index}`]: item, - ...reducedObject, - } - }, {}), binaryOutput: this.binaryData.reduce((reducedObject, item, index) => { return { [`item-${index}`]: item, diff --git a/server/src/workflow-management/integrations/airtable.ts b/server/src/workflow-management/integrations/airtable.ts index 8113bc47..401bc11d 100644 --- a/server/src/workflow-management/integrations/airtable.ts +++ b/server/src/workflow-management/integrations/airtable.ts @@ -14,7 +14,6 @@ interface AirtableUpdateTask { interface SerializableOutput { scrapeSchema?: any[]; scrapeList?: any[]; - other?: any[]; } const MAX_RETRIES = 3; @@ -52,7 +51,6 @@ function mergeRelatedData(serializableOutput: SerializableOutput, binaryOutput: ...[ ...(serializableOutput.scrapeSchema ?? []).map(arr => arr?.length ?? 0), ...(serializableOutput.scrapeList ?? []).map(arr => arr?.length ?? 0), - ...(serializableOutput.other ?? []).map(arr => arr?.length ?? 0), 0 ] ); @@ -83,17 +81,6 @@ function mergeRelatedData(serializableOutput: SerializableOutput, binaryOutput: } } - if (serializableOutput.other) { - for (const otherArray of serializableOutput.other) { - if (!Array.isArray(otherArray)) continue; - - for (let i = 0; i < otherArray.length; i++) { - if (i >= mergedRecords.length) break; - mergedRecords[i] = { ...mergedRecords[i], ...otherArray[i] }; - } - } - } - if (binaryOutput && Object.keys(binaryOutput).length > 0) { for (let i = 0; i < mergedRecords.length; i++) { const screenshotKey = `item-${i}`; diff --git a/server/src/workflow-management/integrations/gsheet.ts b/server/src/workflow-management/integrations/gsheet.ts index 3fbe1229..402ace5d 100644 --- a/server/src/workflow-management/integrations/gsheet.ts +++ b/server/src/workflow-management/integrations/gsheet.ts @@ -13,7 +13,6 @@ interface GoogleSheetUpdateTask { interface SerializableOutput { scrapeSchema?: any[]; scrapeList?: any[]; - other?: any[]; } const MAX_RETRIES = 5; @@ -69,16 +68,6 @@ export async function updateGoogleSheet(robotId: string, runId: string) { plainRobot ); } - - if (serializableOutput.other && serializableOutput.other.length > 0) { - await processOutputType( - robotId, - spreadsheetId, - 'Other', - serializableOutput.other, - plainRobot - ); - } } if (plainRun.binaryOutput && Object.keys(plainRun.binaryOutput).length > 0) { diff --git a/server/src/workflow-management/scheduler/index.ts b/server/src/workflow-management/scheduler/index.ts index bbf845a6..1559e63c 100644 --- a/server/src/workflow-management/scheduler/index.ts +++ b/server/src/workflow-management/scheduler/index.ts @@ -135,7 +135,6 @@ async function executeRun(id: string, userId: string) { const categorizedOutput = { scrapeSchema: interpretationInfo.scrapeSchemaOutput || {}, scrapeList: interpretationInfo.scrapeListOutput || {}, - other: interpretationInfo.otherOutput || {} }; await destroyRemoteBrowser(plainRun.browserId, userId); @@ -149,7 +148,6 @@ async function executeRun(id: string, userId: string) { serializableOutput: { scrapeSchema: Object.values(categorizedOutput.scrapeSchema), scrapeList: Object.values(categorizedOutput.scrapeList), - other: Object.values(categorizedOutput.other), }, binaryOutput: uploadedBinaryOutput, }); diff --git a/src/components/run/InterpretationLog.tsx b/src/components/run/InterpretationLog.tsx index 69608fb5..2695bae4 100644 --- a/src/components/run/InterpretationLog.tsx +++ b/src/components/run/InterpretationLog.tsx @@ -96,17 +96,6 @@ export const InterpretationLog: React.FC = ({ isOpen, se const tabIndex = availableTabs.findIndex(tab => tab.id === 'captureText'); if (tabIndex !== -1) setActiveTab(tabIndex); } - } else if (type === 'other') { - if (Array.isArray(data)) { - setOtherData(prev => [...prev, data]); - } else { - setOtherData(prev => [...prev, [data]]); - } - if (otherData.length === 0) { - const availableTabs = getAvailableTabs(); - const tabIndex = availableTabs.findIndex(tab => tab.id === 'other'); - if (tabIndex !== -1) setActiveTab(tabIndex); - } } scrollLogToBottom(); @@ -178,10 +167,6 @@ export const InterpretationLog: React.FC = ({ isOpen, se tabs.push({ id: 'captureScreenshot', label: 'Screenshots' }); } - if (otherData.length > 0) { - tabs.push({ id: 'other', label: 'Other' }); - } - return tabs; }, [captureListData.length, captureTextData.length, screenshotData.length, otherData.length]); @@ -464,87 +449,6 @@ export const InterpretationLog: React.FC = ({ isOpen, se )} - - {activeTab === availableTabs.findIndex(tab => tab.id === 'other') && otherData.length > 0 && ( - - {otherData.length > 1 && ( - - - {`Dataset ${otherPage + 1} of ${otherData.length}`} - - - - - - - )} - - - - - {otherData[otherPage] && otherData[otherPage].length > 0 && - Object.keys(otherData[otherPage][0]).map((column) => ( - - {column} - - )) - } - - - - {otherData[otherPage] && - otherData[otherPage].map((row: any, idx: any) => ( - - {Object.keys(row).map((column) => ( - - {row[column]} - - ))} - - ))} - -
-
-
- )} ) : ( diff --git a/src/components/run/RunContent.tsx b/src/components/run/RunContent.tsx index 664163aa..781fba70 100644 --- a/src/components/run/RunContent.tsx +++ b/src/components/run/RunContent.tsx @@ -45,9 +45,6 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe const [listData, setListData] = useState([]); const [listColumns, setListColumns] = useState([]); const [currentListIndex, setCurrentListIndex] = useState(0); - - const [otherData, setOtherData] = useState([]); - const [otherColumns, setOtherColumns] = useState([]); const [expandedView, setExpandedView] = useState(null); @@ -66,7 +63,6 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe if (!row.serializableOutput.scrapeSchema && !row.serializableOutput.scrapeList && - !row.serializableOutput.other && Object.keys(row.serializableOutput).length > 0) { setIsLegacyData(true); @@ -83,10 +79,6 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe if (row.serializableOutput.scrapeList) { processScrapeList(row.serializableOutput.scrapeList); } - - if (row.serializableOutput.other && Object.keys(row.serializableOutput.other).length > 0) { - processDataCategory(row.serializableOutput.other, setOtherData, setOtherColumns); - } }, [row.serializableOutput]); const processLegacyData = (legacyOutput: Record) => { @@ -240,7 +232,6 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe allData = { schema: schemaData, list: listData.flat(), - other: otherData }; } @@ -619,13 +610,6 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe csvFilename = 'list_data.csv'; jsonFilename = 'list_data.json'; break; - case 'other': - data = otherData; - columns = otherColumns; - title = t('run_content.captured_data.other_title'); - csvFilename = 'other_data.csv'; - jsonFilename = 'other_data.json'; - break; case 'legacy': data = legacyData; columns = legacyColumns; @@ -714,7 +698,7 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe ); }; - const hasData = schemaData.length > 0 || listData.length > 0 || otherData.length > 0 || legacyData.length > 0; + const hasData = schemaData.length > 0 || listData.length > 0 || legacyData.length > 0; const hasScreenshots = row.binaryOutput && Object.keys(row.binaryOutput).length > 0; return ( @@ -881,15 +865,6 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe 'list_data.json', true )} - - {renderDataTable( - otherData, - otherColumns, - t('run_content.captured_data.other_title'), - , - 'other_data.csv', - 'other_data.json' - )} ) : ( @@ -897,7 +872,6 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe const dataCategoriesCount = [ schemaData.length > 0, listData.length > 0, - otherData.length > 0 ].filter(Boolean).length; const columnWidth = dataCategoriesCount === 1 ? 12 : dataCategoriesCount === 2 ? 6 : 4; @@ -932,20 +906,6 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe )} )} - - {otherData.length > 0 && ( - - {renderDataCard( - otherData, - otherColumns, - t('run_content.captured_data.other_title'), - , - 'other', - 'other_data.csv', - 'other_data.json' - )} - - )} ); })()} @@ -954,7 +914,6 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe )} {renderExpandedView('schema')} - {renderExpandedView('other')} {renderExpandedView('legacy')} {listData.map((_, index) => renderExpandedView(`list-${index}`))}