Browse Source

feat: skip virtual col during data read, pageSize made configurable

Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com>
feat/migration-enhancements
Raju Udava 3 years ago
parent
commit
92138fbc3d
  1. 24
      packages/nocodb/src/lib/noco/meta/api/sync/helpers/job.ts

24
packages/nocodb/src/lib/noco/meta/api/sync/helpers/job.ts

@ -82,6 +82,7 @@ export default async (
const ncSysFields = { id: 'ncRecordId', hash: 'ncRecordHash' }; const ncSysFields = { id: 'ncRecordId', hash: 'ncRecordHash' };
const storeLinks = false; const storeLinks = false;
const ncLinkDataStore: any = {}; const ncLinkDataStore: any = {};
const pageSize = 100;
const uniqueTableNameGen = getUniqueNameGenerator('sheet'); const uniqueTableNameGen = getUniqueNameGenerator('sheet');
@ -1375,14 +1376,20 @@ export default async (
return rec; return rec;
} }
async function nocoReadData(sDB, table) { async function nocoReadData(sDB, table, aTbl) {
ncLinkDataStore[table.title] = {}; ncLinkDataStore[table.title] = {};
const insertJobs: Promise<any>[] = []; const insertJobs: Promise<any>[] = [];
// skip virtual columns
const fieldsArray = aTbl.columns
.filter(a => !['formula', 'lookup', 'rollup'].includes(a.type))
.map(a => a.name);
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
base(table.title) base(table.title)
.select({ .select({
pageSize: 100 pageSize: pageSize,
fields: fieldsArray
// maxRecords: 1, // maxRecords: 1,
}) })
.eachPage( .eachPage(
@ -1391,7 +1398,8 @@ export default async (
// This function (`page`) will get called for each page of records. // This function (`page`) will get called for each page of records.
logBasic( logBasic(
`:: ${table.title} : ${recordCnt + 1} ~ ${(recordCnt += 100)}` `:: ${table.title} : ${recordCnt +
1} ~ ${(recordCnt += pageSize)}`
); );
// await Promise.all( // await Promise.all(
@ -1444,7 +1452,7 @@ export default async (
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
base(table.title) base(table.title)
.select({ .select({
pageSize: 100, pageSize: pageSize,
// maxRecords: 100, // maxRecords: 100,
fields: fields fields: fields
}) })
@ -1456,7 +1464,7 @@ export default async (
// records.forEach(record => callback(table, record)); // records.forEach(record => callback(table, record));
logBasic( logBasic(
`:: ${table.title} / ${fields} : ${recordCnt + `:: ${table.title} / ${fields} : ${recordCnt +
1} ~ ${(recordCnt += 100)}` 1} ~ ${(recordCnt += pageSize)}`
); );
await Promise.all( await Promise.all(
records.map(r => callback(projName, table, r, fields)) records.map(r => callback(projName, table, r, fields))
@ -2193,11 +2201,11 @@ export default async (
recordPerfStats(_perfStart, 'dbTable.read'); recordPerfStats(_perfStart, 'dbTable.read');
// not a migrated table, skip // not a migrated table, skip
if (undefined === aTblSchema.find(x => x.name === ncTbl.title)) const aTbl = aTblSchema.find(x => x.name === ncTbl.title);
continue; if (undefined === aTbl) continue;
recordCnt = 0; recordCnt = 0;
await nocoReadData(syncDB, ncTbl); await nocoReadData(syncDB, ncTbl, aTbl);
logDetailed(`Data inserted from ${ncTbl.title}`); logDetailed(`Data inserted from ${ncTbl.title}`);
} }

Loading…
Cancel
Save