feat: add memory cache to boost performance (#2620)
* feat: add memory cache to boost performance * fix: tests * fix: logging * fix: missing commented stuff
This commit is contained in:
@ -0,0 +1,11 @@
|
||||
export class WorkspaceMigrationAppliedEvent {
|
||||
private readonly _workspaceId: string;
|
||||
|
||||
constructor(worskapceId: string) {
|
||||
this._workspaceId = worskapceId;
|
||||
}
|
||||
|
||||
get workspaceId(): string {
|
||||
return this._workspaceId;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
export enum WorkspaceMigrationEvents {
|
||||
MigrationApplied = '@workspace/migration-applied',
|
||||
}
|
||||
@ -1,4 +1,5 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { EventEmitter2 } from '@nestjs/event-emitter';
|
||||
|
||||
import {
|
||||
QueryRunner,
|
||||
@ -17,6 +18,8 @@ import {
|
||||
WorkspaceMigrationColumnCreate,
|
||||
WorkspaceMigrationColumnRelation,
|
||||
} from 'src/metadata/workspace-migration/workspace-migration.entity';
|
||||
import { WorkspaceMigrationEvents } from 'src/workspace/workspace-migration-runner/events/workspace-migration-events';
|
||||
import { WorkspaceMigrationAppliedEvent } from 'src/workspace/workspace-migration-runner/events/workspace-migration-applied.event';
|
||||
|
||||
import { customTableDefaultColumns } from './utils/custom-table-default-column.util';
|
||||
|
||||
@ -25,6 +28,7 @@ export class WorkspaceMigrationRunnerService {
|
||||
constructor(
|
||||
private readonly workspaceDataSourceService: WorkspaceDataSourceService,
|
||||
private readonly workspaceMigrationService: WorkspaceMigrationService,
|
||||
private readonly eventEmitter: EventEmitter2,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@ -78,6 +82,12 @@ export class WorkspaceMigrationRunnerService {
|
||||
|
||||
await queryRunner.release();
|
||||
|
||||
// Emit event when migration is applied
|
||||
this.eventEmitter.emit(
|
||||
WorkspaceMigrationEvents.MigrationApplied,
|
||||
new WorkspaceMigrationAppliedEvent(workspaceId),
|
||||
);
|
||||
|
||||
return flattenedPendingMigrations;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user