-
-
Notifications
You must be signed in to change notification settings - Fork 634
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: using worker parse csv * fix: import multiple column error * feat: update webpack config for import worker * fix: vitest worker file path error * fix: excel import missing key * feat: using `convertCellValue2DBValue` transfer cellvalue * feat: add workerId escape conflict * fix: sqlite e2e error * feat: compact filter input
- Loading branch information
Showing
12 changed files
with
482 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { parentPort, workerData } from 'worker_threads'; | ||
import { getRandomString } from '@teable/core'; | ||
import type { IImportConstructorParams } from '../features/import/open-api/import.class'; | ||
import { importerFactory } from '../features/import/open-api/import.class'; | ||
|
||
const parse = () => { | ||
const { config, options, id } = { ...workerData } as { | ||
config: IImportConstructorParams; | ||
options: { | ||
skipFirstNLines: number; | ||
key: string; | ||
}; | ||
id: string; | ||
}; | ||
const importer = importerFactory(config.type, config); | ||
importer.parse( | ||
{ ...options }, | ||
async (chunk) => { | ||
return await new Promise((resolve) => { | ||
const chunkId = `chunk_${getRandomString(8)}`; | ||
parentPort?.postMessage({ type: 'chunk', data: chunk, chunkId, id }); | ||
parentPort?.on('message', (result) => { | ||
const { type, chunkId: tunnelChunkId } = result; | ||
if (type === 'done' && tunnelChunkId === chunkId) { | ||
resolve(); | ||
} | ||
}); | ||
}); | ||
}, | ||
() => { | ||
parentPort?.postMessage({ type: 'finished', id }); | ||
parentPort?.close(); | ||
}, | ||
(error) => { | ||
parentPort?.postMessage({ type: 'error', data: error, id }); | ||
parentPort?.close(); | ||
} | ||
); | ||
}; | ||
|
||
parse(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.