fix(core): update

This commit is contained in:
2022-07-27 22:42:08 +02:00
parent bd9b3bb985
commit af3d461593
7 changed files with 53 additions and 20 deletions

View File

@@ -66,6 +66,7 @@ export class TimeDataTable {
}
// INSTANCE
public healingDeferred: plugins.smartpromise.Deferred<any>;
public smartClickHouseDbRef: SmartClickHouseDb;
public options: ITimeDataTableOptions;
@@ -92,6 +93,7 @@ export class TimeDataTable {
* stores a json and tries to map it to the nested syntax
*/
public async addData(dataArg: any) {
// the storageJson
let storageJson: { [key: string]: any } = {};
@@ -164,7 +166,18 @@ export class TimeDataTable {
const result = await this.smartClickHouseDbRef.clickhouseClient.insertPromise(this.options.tableName, [
storageJson,
]);
]).catch(async () => {
if (this.healingDeferred) {
return;
}
this.healingDeferred = plugins.smartpromise.defer();
console.log(`Ran into an error. Trying to set up things properly again.`);
await this.smartClickHouseDbRef.pingDatabaseUntilAvailable();
await this.smartClickHouseDbRef.createDatabase();
this.columns = [];
this.healingDeferred.resolve();
this.healingDeferred = null;
});
return result;
}
}