(datasetId: string, rows: any[], workspaceId: string)
| 91 | } |
| 92 | |
| 93 | const reorderDatasetRow = async (datasetId: string, rows: any[], workspaceId: string) => { |
| 94 | try { |
| 95 | const appServer = getRunningExpressApp() |
| 96 | await appServer.AppDataSource.transaction(async (entityManager) => { |
| 97 | // rows are an array of { id: string, sequenceNo: number } |
| 98 | // update the sequence numbers in the DB |
| 99 | for (const row of rows) { |
| 100 | const item = await entityManager.getRepository(DatasetRow).findOneBy({ |
| 101 | id: row.id |
| 102 | }) |
| 103 | if (!item) throw new InternalFlowiseError(StatusCodes.NOT_FOUND, `Dataset Row ${row.id} not found`) |
| 104 | item.sequenceNo = row.sequenceNo |
| 105 | await entityManager.getRepository(DatasetRow).save(item) |
| 106 | } |
| 107 | await changeUpdateOnDataset(datasetId, workspaceId, entityManager) |
| 108 | }) |
| 109 | return { message: 'Dataset row reordered successfully' } |
| 110 | } catch (error) { |
| 111 | throw new InternalFlowiseError( |
| 112 | StatusCodes.INTERNAL_SERVER_ERROR, |
| 113 | `Error: datasetService.reorderDatasetRow - ${getErrorMessage(error)}` |
| 114 | ) |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | const _readCSV = async (stream: Readable, results: any[]) => { |
| 119 | return new Promise((resolve, reject) => { |
nothing calls this directly
no test coverage detected