mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-24 12:19:08 +00:00
FEAT: update job deletion and mark associated table as deleted in DynamoDB. Update protospack-v2
This commit is contained in:
@@ -48,6 +48,7 @@ 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';
|
||||
@@ -64,6 +65,7 @@ export class PipelinesController {
|
||||
dadosferaLogger: DadosferaLogger,
|
||||
private pipelinesClientService: PipelinesService,
|
||||
private oldPipelinesService: OldPipelineService,
|
||||
private platformApiService: PlatformApiService,
|
||||
) {
|
||||
this.logger = dadosferaLogger.logger;
|
||||
}
|
||||
@@ -222,31 +224,40 @@ export class PipelinesController {
|
||||
language,
|
||||
});
|
||||
|
||||
const result = await this.pipelinesClientService
|
||||
.findOne({ id }, metadata)
|
||||
.then(async (res) => {
|
||||
//{pipeline:{tables: {tables: [], input_id: ''}}}
|
||||
const parsed = JSON.parse(res.pipeline.config.tables);
|
||||
const input_id = parsed?.input_id;
|
||||
const tables = parsed?.tables ?? parsed;
|
||||
const [pipelineRes, platformPipeline] = await Promise.all([
|
||||
this.pipelinesClientService.findOne({ id }, metadata),
|
||||
this.platformApiService.proxy('GET', `/pipeline/${id.replace(/-/g, '_')}`, user).catch(() => null),
|
||||
]);
|
||||
|
||||
Object.assign(res.pipeline, {
|
||||
transformations: res.pipeline.transformations
|
||||
? JSON.parse(res.pipeline.transformations)
|
||||
: [],
|
||||
config: {
|
||||
cron: res.pipeline.config.cron,
|
||||
tables,
|
||||
input_id
|
||||
},
|
||||
properties: res.pipeline.properties
|
||||
? JSON.parse(res.pipeline.properties)
|
||||
: {},
|
||||
});
|
||||
return res;
|
||||
//{pipeline:{tables: {tables: [], input_id: ''}}}
|
||||
type PipelineTablesConfig = { input_id?: string; tables?: Array<{ name: string }> } | Array<{ name: string }>;
|
||||
const parsed: PipelineTablesConfig = JSON.parse(pipelineRes.pipeline.config.tables);
|
||||
const input_id = (parsed as { input_id?: string })?.input_id;
|
||||
let tables: Array<any> = (parsed as { tables?: Array<any> })?.tables ?? (parsed as Array<any>);
|
||||
|
||||
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;
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
Object.assign(pipelineRes.pipeline, {
|
||||
transformations: pipelineRes.pipeline.transformations
|
||||
? JSON.parse(pipelineRes.pipeline.transformations)
|
||||
: [],
|
||||
config: {
|
||||
cron: pipelineRes.pipeline.config.cron,
|
||||
tables,
|
||||
input_id,
|
||||
},
|
||||
properties: pipelineRes.pipeline.properties
|
||||
? JSON.parse(pipelineRes.pipeline.properties)
|
||||
: {},
|
||||
});
|
||||
|
||||
return pipelineRes;
|
||||
}
|
||||
|
||||
@Patch('/:id')
|
||||
|
||||
Reference in New Issue
Block a user