Browse Source

refactor: use logWarning for errors

pull/7476/head
mertmit 11 months ago
parent
commit
ac76353a0d
  1. 10
      packages/nocodb/src/modules/jobs/jobs/at-import/at-import.processor.ts
  2. 36
      packages/nocodb/src/modules/jobs/jobs/at-import/helpers/readAndProcessData.ts

10
packages/nocodb/src/modules/jobs/jobs/at-import/at-import.processor.ts

@ -2483,14 +2483,15 @@ export class AtImportProcessor {
baseName: syncDB.baseId, baseName: syncDB.baseId,
table: ncTbl, table: ncTbl,
atBase, atBase,
logBasic,
nocoBaseDataProcessing_v2, nocoBaseDataProcessing_v2,
sDB: syncDB, sDB: syncDB,
logDetailed,
services: { services: {
tableService: this.tablesService, tableService: this.tablesService,
bulkDataService: this.bulkDataAliasService, bulkDataService: this.bulkDataAliasService,
}, },
logBasic,
logDetailed,
logWarning,
}); });
rtc.data.records += await recordsMap[ncTbl.id].getCount(); rtc.data.records += await recordsMap[ncTbl.id].getCount();
@ -2518,9 +2519,7 @@ export class AtImportProcessor {
baseName: syncDB.baseId, baseName: syncDB.baseId,
atBase, atBase,
fields: null, //Object.values(tblLinkGroup).flat(), fields: null, //Object.values(tblLinkGroup).flat(),
logBasic,
insertedAssocRef, insertedAssocRef,
logDetailed,
records: recordsMap[ncTbl.id], records: recordsMap[ncTbl.id],
atNcAliasRef, atNcAliasRef,
ncLinkMappingTable, ncLinkMappingTable,
@ -2529,6 +2528,9 @@ export class AtImportProcessor {
tableService: this.tablesService, tableService: this.tablesService,
bulkDataService: this.bulkDataAliasService, bulkDataService: this.bulkDataAliasService,
}, },
logBasic,
logDetailed,
logWarning,
}); });
} }
} catch (error) { } catch (error) {

36
packages/nocodb/src/modules/jobs/jobs/at-import/helpers/readAndProcessData.ts

@ -26,12 +26,14 @@ async function readAllData({
fields, fields,
atBase, atBase,
logBasic = (_str) => {}, logBasic = (_str) => {},
logWarning = (_str) => {},
}: { }: {
table: { title?: string }; table: { title?: string };
fields?; fields?;
atBase: AirtableBase; atBase: AirtableBase;
logBasic?: (string) => void; logBasic?: (string) => void;
logDetailed?: (string) => void; logDetailed?: (string) => void;
logWarning?: (string) => void;
}): Promise<EntityMap> { }): Promise<EntityMap> {
return new Promise((resolve) => { return new Promise((resolve) => {
let data = null; let data = null;
@ -78,8 +80,8 @@ async function readAllData({
async function done(err) { async function done(err) {
if (err) { if (err) {
logger.error(err); logger.error(err);
logBasic( logWarning(
`:: There were errors on reading '${table.title}' data :: ${err}`, `There were errors on reading '${table.title}' data :: ${err}`,
); );
} }
resolve(data); resolve(data);
@ -94,8 +96,9 @@ export async function importData({
atBase, atBase,
nocoBaseDataProcessing_v2, nocoBaseDataProcessing_v2,
sDB, sDB,
logDetailed = (_str) => {},
logBasic = (_str) => {}, logBasic = (_str) => {},
logDetailed = (_str) => {},
logWarning = (_str) => {},
services, services,
}: { }: {
baseName: string; baseName: string;
@ -104,6 +107,7 @@ export async function importData({
atBase: AirtableBase; atBase: AirtableBase;
logBasic: (string) => void; logBasic: (string) => void;
logDetailed: (string) => void; logDetailed: (string) => void;
logWarning: (string) => void;
nocoBaseDataProcessing_v2; nocoBaseDataProcessing_v2;
sDB; sDB;
services: AirtableImportContext; services: AirtableImportContext;
@ -179,8 +183,8 @@ export async function importData({
resolve(true); resolve(true);
} catch (e) { } catch (e) {
logger.error(e); logger.error(e);
logBasic( logWarning(
`:: There were errors on importing '${table.title}' data :: ${e}`, `There were errors on importing '${table.title}' data :: ${e}`,
); );
readable.resume(); readable.resume();
resolve(true); resolve(true);
@ -217,8 +221,8 @@ export async function importData({
resolve(true); resolve(true);
} catch (e) { } catch (e) {
logger.error(e); logger.error(e);
logBasic( logWarning(
`:: There were errors on importing '${table.title}' data :: ${e}`, `There were errors on importing '${table.title}' data :: ${e}`,
); );
resolve(true); resolve(true);
} }
@ -237,20 +241,19 @@ export async function importLTARData({
atBase, atBase,
baseName, baseName,
insertedAssocRef = {}, insertedAssocRef = {},
logDetailed = (_str) => {},
logBasic = (_str) => {},
records, records,
atNcAliasRef, atNcAliasRef,
ncLinkMappingTable, ncLinkMappingTable,
syncDB, syncDB,
services, services,
logBasic = (_str) => {},
logDetailed = (_str) => {},
logWarning = (_str) => {},
}: { }: {
baseName: string; baseName: string;
table: { title?: string; id?: string }; table: { title?: string; id?: string };
fields; fields;
atBase: AirtableBase; atBase: AirtableBase;
logDetailed: (string) => void;
logBasic: (string) => void;
insertedAssocRef: { [assocTableId: string]: boolean }; insertedAssocRef: { [assocTableId: string]: boolean };
records?: EntityMap; records?: EntityMap;
atNcAliasRef: { atNcAliasRef: {
@ -261,6 +264,9 @@ export async function importLTARData({
ncLinkMappingTable: Record<string, Record<string, any>>[]; ncLinkMappingTable: Record<string, Record<string, any>>[];
syncDB; syncDB;
services: AirtableImportContext; services: AirtableImportContext;
logBasic: (string) => void;
logDetailed: (string) => void;
logWarning: (string) => void;
}) { }) {
const assocTableMetas: Array<{ const assocTableMetas: Array<{
modelMeta: { id?: string; title?: string }; modelMeta: { id?: string; title?: string };
@ -379,8 +385,8 @@ export async function importLTARData({
resolve(true); resolve(true);
} catch (e) { } catch (e) {
logger.error(e); logger.error(e);
logBasic( logWarning(
`:: There were errors on importing '${table.title}' LTAR data :: ${e}`, `There were errors on importing '${table.title}' LTAR data :: ${e}`,
); );
readable.resume(); readable.resume();
resolve(true); resolve(true);
@ -418,8 +424,8 @@ export async function importLTARData({
resolve(true); resolve(true);
} catch (e) { } catch (e) {
logger.error(e); logger.error(e);
logBasic( logWarning(
`:: There were errors on importing '${table.title}' LTAR data :: ${e}`, `There were errors on importing '${table.title}' LTAR data :: ${e}`,
); );
resolve(true); resolve(true);
} }

Loading…
Cancel
Save