From 46037de01c936a5b209175446d4e539abbd644ab Mon Sep 17 00:00:00 2001 From: Nevo David Date: Wed, 13 Mar 2024 09:49:56 +0700 Subject: [PATCH] feat: missing payload --- apps/cron/src/tasks/check.stars.ts | 33 ++++++++++++++++-------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/apps/cron/src/tasks/check.stars.ts b/apps/cron/src/tasks/check.stars.ts index 43603036..c76bc00b 100644 --- a/apps/cron/src/tasks/check.stars.ts +++ b/apps/cron/src/tasks/check.stars.ts @@ -1,20 +1,23 @@ import { Injectable } from '@nestjs/common'; -import {Cron} from '@nestjs/schedule'; -import {StarsService} from "@gitroom/nestjs-libraries/database/prisma/stars/stars.service"; -import {BullMqClient} from "@gitroom/nestjs-libraries/bull-mq-transport/client/bull-mq.client"; +import { Cron } from '@nestjs/schedule'; +import { StarsService } from '@gitroom/nestjs-libraries/database/prisma/stars/stars.service'; +import { BullMqClient } from '@gitroom/nestjs-libraries/bull-mq-transport/client/bull-mq.client'; @Injectable() export class CheckStars { - constructor( - private _starsService: StarsService, - private _workerServiceProducer: BullMqClient - ) { + constructor( + private _starsService: StarsService, + private _workerServiceProducer: BullMqClient + ) {} + @Cron('0 0 * * *') + async checkStars() { + const allGitHubRepositories = + await this._starsService.getAllGitHubRepositories(); + for (const repository of allGitHubRepositories) { + this._workerServiceProducer.emit( + 'check_stars', + JSON.stringify({ payload: { login: repository.login } }) + ); } - @Cron('0 0 * * *') - async checkStars() { - const allGitHubRepositories = await this._starsService.getAllGitHubRepositories(); - for (const repository of allGitHubRepositories) { - this._workerServiceProducer.emit('check_stars', JSON.stringify({login: repository.login})); - } - } -} \ No newline at end of file + } +}