fennec-be/src/pipeline-tasks/models/pipeline-task-log-message.module.ts

35 lines
761 B
TypeScript

import { PipelineTask } from './../pipeline-task.entity';
import { PipelineUnits } from '../enums/pipeline-units.enum';
import { Field, HideField, ObjectType } from '@nestjs/graphql';
import { Type } from 'class-transformer';
@ObjectType()
export class PipelineTaskLogMessage {
@HideField()
task: PipelineTask;
@Field(() => PipelineUnits, { nullable: true })
unit?: PipelineUnits;
@Field()
@Type(() => Date)
time: Date;
@Field()
message: string;
@Field()
isError: boolean;
static create(
task: PipelineTask,
unit: PipelineUnits,
message: string,
isError: boolean,
) {
return Object.assign(new PipelineTaskLogMessage(), {
task,
message,
time: new Date(),
unit,
isError,
});
}
}