fennec-be/src/repos/list-logs.consumer.ts

25 lines
731 B
TypeScript
Raw Normal View History

import { PubSub } from 'graphql-subscriptions';
import { ReposService } from './repos.service';
import { Processor, Process } from '@nestjs/bull';
import { Job } from 'bull';
import { ListLogsOption } from './models/list-logs.options';
import {
LIST_LOGS_DONE,
LIST_LOGS_PUB_SUB,
LIST_LOGS_TASK,
} from './repos.constants';
import { Inject } from '@nestjs/common';
@Processor(LIST_LOGS_TASK)
export class ListLogsConsumer {
constructor(
private readonly service: ReposService,
@Inject(LIST_LOGS_PUB_SUB)
private readonly pubSub: PubSub,
) {}
@Process()
async listLogs(job: Job<ListLogsOption>) {
const logs = await this.service.listLogs(job.data);
this.pubSub.publish(LIST_LOGS_DONE, logs);
}
}