mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-27 19:40:05 +00:00
FEAT: update job deletion endpoint to include inputId in path and implement rollback for table deletion
This commit is contained in:
@@ -48,7 +48,6 @@ import {
|
||||
import { GrpcToHttpExceptionFilter } from 'src/error/grpc-to-http-exception.filter';
|
||||
import { LanguageEnum } from 'src/utils/languages.enum';
|
||||
import { Language } from 'src/decorators/language.decorator';
|
||||
import { PlatformApiService } from '../platform-api/platform-api.service';
|
||||
import { ApiInternalOnlyEndpoint } from 'src/decorators/swagger.decorator';
|
||||
import { TableColumns } from '../inputs/dtos/input.model';
|
||||
import { UpdateInputRequest } from '../inputs/dtos/old_interfaces';
|
||||
@@ -69,7 +68,6 @@ export class PipelinesController {
|
||||
|
||||
private pipelinesClientService: PipelinesService,
|
||||
private oldPipelinesService: OldPipelineService,
|
||||
private platformApiService: PlatformApiService,
|
||||
) {
|
||||
this.logger = dadosferaLogger.logger;
|
||||
}
|
||||
@@ -228,22 +226,14 @@ export class PipelinesController {
|
||||
language,
|
||||
});
|
||||
|
||||
const [pipelineRes, platformPipeline] = await Promise.all([
|
||||
this.pipelinesClientService.findOne({ id }, metadata),
|
||||
this.platformApiService.proxy('GET', `/pipeline/${id.replace(/-/g, '_')}`, user).catch(() => null),
|
||||
]);
|
||||
const pipelineRes = await this.pipelinesClientService.findOne({ id }, metadata);
|
||||
|
||||
const parsed: PipelineTablesConfig = JSON.parse(pipelineRes.pipeline.config.tables);
|
||||
const input_id = (parsed as { input_id?: string; tables?: PipelineTable[] })?.input_id;
|
||||
let tables: PipelineTable[] = (parsed as { tables?: PipelineTable[] })?.tables ?? (parsed as PipelineTable[]);
|
||||
|
||||
if (platformPipeline?.jobs?.length) {
|
||||
tables = tables.map((table) => {
|
||||
const job = (platformPipeline.jobs as Array<{ job_id: string; input?: { table_name: string } }>)
|
||||
.find((j) => j.input?.table_name === table.name);
|
||||
return job ? { ...table, job_id: job.job_id } : table;
|
||||
});
|
||||
}
|
||||
const normalizedId = id.replace(/-/g, '_');
|
||||
const tables: PipelineTable[] = (
|
||||
(parsed as { tables?: PipelineTable[] })?.tables ?? (parsed as PipelineTable[])
|
||||
).map((table, index) => ({ ...table, job_id: `${normalizedId}_${index}` }));
|
||||
|
||||
Object.assign(pipelineRes.pipeline, {
|
||||
transformations: pipelineRes.pipeline.transformations
|
||||
|
||||
Reference in New Issue
Block a user