From 3eebb8e2c4452a816386614b484dd70edb79792a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daute=20Rodr=C3=ADguez=20Rodr=C3=ADguez?= <94375891+aciddaute@users.noreply.github.com> Date: Mon, 9 May 2022 15:47:29 +0100 Subject: [PATCH] feat: import legacy projects api events (#1047) * feat: import legacy projects api events * feat: import legacy projects piece api events --- ...652734-AddImportLegacyProjectsApiEvents.ts | 42 +++++++++++++++++++ .../project-status.view.api.entity.ts | 12 ++++++ .../api-events/src/api-event-kinds.enum.ts | 6 +++ 3 files changed, 60 insertions(+) create mode 100644 api/apps/api/src/migrations/api/1652099652734-AddImportLegacyProjectsApiEvents.ts diff --git a/api/apps/api/src/migrations/api/1652099652734-AddImportLegacyProjectsApiEvents.ts b/api/apps/api/src/migrations/api/1652099652734-AddImportLegacyProjectsApiEvents.ts new file mode 100644 index 0000000000..92bbd15ac0 --- /dev/null +++ b/api/apps/api/src/migrations/api/1652099652734-AddImportLegacyProjectsApiEvents.ts @@ -0,0 +1,42 @@ +import { MigrationInterface, QueryRunner } from 'typeorm'; + +export class AddImportLegacyProjectsApiEvents1652099652734 + implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(` + INSERT INTO api_event_kinds (id) values + ('project.legacy.import.submitted/v1/alpha'), + ('project.legacy.import.finished/v1/alpha'), + ('project.legacy.import.failed/v1/alpha'), + ('project.legacy.import.piece.submitted/v1/alpha'), + ('project.legacy.import.piece.finished/v1/alpha'), + ('project.legacy.import.piece.failed/v1/alpha'); + `); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `DELETE FROM api_event_kinds WHERE id = 'project.legacy.import.submitted/v1/alpha';`, + ); + + await queryRunner.query( + `DELETE FROM api_event_kinds WHERE id = 'project.legacy.import.finished/v1/alpha';`, + ); + + await queryRunner.query( + `DELETE FROM api_event_kinds WHERE id = 'project.legacy.import.failed/v1/alpha';`, + ); + + await queryRunner.query( + `DELETE FROM api_event_kinds WHERE id = 'project.legacy.import.piece.submitted/v1/alpha';`, + ); + + await queryRunner.query( + `DELETE FROM api_event_kinds WHERE id = 'project.legacy.import.piece.finished/v1/alpha';`, + ); + + await queryRunner.query( + `DELETE FROM api_event_kinds WHERE id = 'project.legacy.import.piece.failed/v1/alpha';`, + ); + } +} diff --git a/api/apps/api/src/modules/projects/job-status/project-status.view.api.entity.ts b/api/apps/api/src/modules/projects/job-status/project-status.view.api.entity.ts index caceba79ee..3fcfb662a5 100644 --- a/api/apps/api/src/modules/projects/job-status/project-status.view.api.entity.ts +++ b/api/apps/api/src/modules/projects/job-status/project-status.view.api.entity.ts @@ -76,4 +76,16 @@ const eventToJobStatusMapping: Record, JobStatus> = { [API_EVENT_KINDS.project__clone__failed__v1__alpha]: JobStatus.failure, [API_EVENT_KINDS.project__clone__finished__v1__alpha]: JobStatus.done, [API_EVENT_KINDS.project__clone__submitted__v1__alpha]: JobStatus.running, + [API_EVENT_KINDS.project__legacy__import__failed__v1__alpha]: + JobStatus.failure, + [API_EVENT_KINDS.project__legacy__import__finished__v1__alpha]: + JobStatus.done, + [API_EVENT_KINDS.project__legacy__import__submitted__v1__alpha]: + JobStatus.running, + [API_EVENT_KINDS.project__legacy__import__piece__failed__v1__alpha]: + JobStatus.failure, + [API_EVENT_KINDS.project__legacy__import__piece__finished__v1__alpha]: + JobStatus.done, + [API_EVENT_KINDS.project__legacy__import__piece__submitted__v1__alpha]: + JobStatus.running, }; diff --git a/api/libs/api-events/src/api-event-kinds.enum.ts b/api/libs/api-events/src/api-event-kinds.enum.ts index 560754bce2..75dddf89d6 100644 --- a/api/libs/api-events/src/api-event-kinds.enum.ts +++ b/api/libs/api-events/src/api-event-kinds.enum.ts @@ -82,6 +82,12 @@ export enum API_EVENT_KINDS { scenario__clone__submitted__v1__alpha = 'scenario.clone.submitted/v1/alpha', scenario__clone__finished__v1__alpha = 'scenario.clone.finished/v1/alpha', scenario__clone__failed__v1__alpha = 'scenario.clone.failed/v1/alpha', + project__legacy__import__submitted__v1__alpha = 'project.legacy.import.submitted/v1/alpha', + project__legacy__import__finished__v1__alpha = 'project.legacy.import.finished/v1/alpha', + project__legacy__import__failed__v1__alpha = 'project.legacy.import.failed/v1/alpha', + project__legacy__import__piece__submitted__v1__alpha = 'project.legacy.import.piece.submitted/v1/alpha', + project__legacy__import__piece__finished__v1__alpha = 'project.legacy.import.piece.finished/v1/alpha', + project__legacy__import__piece__failed__v1__alpha = 'project.legacy.import.piece.failed/v1/alpha', } export type ProjectEvents = Pick<