|
|
@ -86,7 +86,27 @@ export class DuplicateProcessor { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const handledLinks = []; |
|
|
|
const handledLinks = []; |
|
|
|
const lChunk: Record<string, any[]> = {}; // fk_mm_model_id: { rowId, childId }[]
|
|
|
|
const lChunks: Record<string, any[]> = {}; // fk_mm_model_id: { rowId, childId }[]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const insertChunks = async () => { |
|
|
|
|
|
|
|
for (const [k, v] of Object.entries(lChunks)) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
if (v.length === 0) continue; |
|
|
|
|
|
|
|
await this.bulkDataService.bulkDataInsert({ |
|
|
|
|
|
|
|
projectName: dupProject.id, |
|
|
|
|
|
|
|
tableName: k, |
|
|
|
|
|
|
|
body: v, |
|
|
|
|
|
|
|
cookie: null, |
|
|
|
|
|
|
|
chunkSize: 1000, |
|
|
|
|
|
|
|
foreign_key_checks: false, |
|
|
|
|
|
|
|
raw: true, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
lChunks[k] = []; |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
|
|
console.log(e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
for (const sourceModel of models) { |
|
|
|
for (const sourceModel of models) { |
|
|
|
const dataStream = new Readable({ |
|
|
|
const dataStream = new Readable({ |
|
|
@ -226,7 +246,7 @@ export class DuplicateProcessor { |
|
|
|
const mmModelId = |
|
|
|
const mmModelId = |
|
|
|
mmColumns[columnId].colOptions.fk_mm_model_id; |
|
|
|
mmColumns[columnId].colOptions.fk_mm_model_id; |
|
|
|
const mm = mmParentChild[mmModelId]; |
|
|
|
const mm = mmParentChild[mmModelId]; |
|
|
|
lChunk[mmModelId].push({ |
|
|
|
lChunks[mmModelId].push({ |
|
|
|
[mm.parent]: parent, |
|
|
|
[mm.parent]: parent, |
|
|
|
[mm.child]: child, |
|
|
|
[mm.child]: child, |
|
|
|
}); |
|
|
|
}); |
|
|
@ -234,6 +254,8 @@ export class DuplicateProcessor { |
|
|
|
// get column for the first time
|
|
|
|
// get column for the first time
|
|
|
|
parser.pause(); |
|
|
|
parser.pause(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await insertChunks(); |
|
|
|
|
|
|
|
|
|
|
|
const col = await Column.get({ |
|
|
|
const col = await Column.get({ |
|
|
|
base_id: dupBaseId, |
|
|
|
base_id: dupBaseId, |
|
|
|
colId: findWithIdentifier(idMap, columnId), |
|
|
|
colId: findWithIdentifier(idMap, columnId), |
|
|
@ -257,11 +279,11 @@ export class DuplicateProcessor { |
|
|
|
const mmModelId = col.colOptions.fk_mm_model_id; |
|
|
|
const mmModelId = col.colOptions.fk_mm_model_id; |
|
|
|
|
|
|
|
|
|
|
|
// create chunk
|
|
|
|
// create chunk
|
|
|
|
lChunk[mmModelId] = []; |
|
|
|
lChunks[mmModelId] = []; |
|
|
|
|
|
|
|
|
|
|
|
// push to chunk
|
|
|
|
// push to chunk
|
|
|
|
const mm = mmParentChild[mmModelId]; |
|
|
|
const mm = mmParentChild[mmModelId]; |
|
|
|
lChunk[mmModelId].push({ |
|
|
|
lChunks[mmModelId].push({ |
|
|
|
[mm.parent]: parent, |
|
|
|
[mm.parent]: parent, |
|
|
|
[mm.child]: child, |
|
|
|
[mm.child]: child, |
|
|
|
}); |
|
|
|
}); |
|
|
@ -273,6 +295,7 @@ export class DuplicateProcessor { |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
complete: async () => { |
|
|
|
complete: async () => { |
|
|
|
|
|
|
|
await insertChunks(); |
|
|
|
resolve(null); |
|
|
|
resolve(null); |
|
|
|
}, |
|
|
|
}, |
|
|
|
}); |
|
|
|
}); |
|
|
@ -281,22 +304,6 @@ export class DuplicateProcessor { |
|
|
|
elapsedTime(model.title); |
|
|
|
elapsedTime(model.title); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (const [k, v] of Object.entries(lChunk)) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
await this.bulkDataService.bulkDataInsert({ |
|
|
|
|
|
|
|
projectName: dupProject.id, |
|
|
|
|
|
|
|
tableName: k, |
|
|
|
|
|
|
|
body: v, |
|
|
|
|
|
|
|
cookie: null, |
|
|
|
|
|
|
|
chunkSize: 1000, |
|
|
|
|
|
|
|
foreign_key_checks: false, |
|
|
|
|
|
|
|
raw: true, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
|
|
console.log(e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elapsedTime('links'); |
|
|
|
elapsedTime('links'); |
|
|
|
await this.projectsService.projectUpdate({ |
|
|
|
await this.projectsService.projectUpdate({ |
|
|
|
projectId: dupProject.id, |
|
|
|
projectId: dupProject.id, |
|
|
|