refactor: Improve code readability and maintainability in AnalyticsDatabaseService.ts

This commit is contained in:
Simon Larsen 2024-05-03 19:05:56 +01:00
parent aede9af03d
commit 469e06280a
No known key found for this signature in database
GPG Key ID: 96C5DCA24769DBCA

View File

@ -53,14 +53,14 @@ import TableColumnType from 'Common/Types/AnalyticsDatabase/TableColumnType';
export default class AnalyticsDatabaseService<
TBaseModel extends AnalyticsBaseModel
> extends BaseService {
public modelType!: { new(): TBaseModel };
public modelType!: { new (): TBaseModel };
public database!: ClickhouseDatabase;
public model!: TBaseModel;
public databaseClient!: ClickhouseClient;
public statementGenerator!: StatementGenerator<TBaseModel>;
public constructor(data: {
modelType: { new(): TBaseModel };
modelType: { new (): TBaseModel };
database?: ClickhouseDatabase | undefined;
}) {
super();
@ -765,7 +765,8 @@ export default class AnalyticsDatabaseService<
await Promise.allSettled(promises);
} else {
logger.warn(
`Realtime is not initialized. Skipping emitModelEvent for ${this.getModel().tableName
`Realtime is not initialized. Skipping emitModelEvent for ${
this.getModel().tableName
}`
);
}
@ -868,7 +869,6 @@ export default class AnalyticsDatabaseService<
requiredField,
data.getDefaultValueForColumn(requiredField)
);
} else {
throw new BadDataException(`${requiredField} is required`);
}