Skip to content

πŸ“¨ The ultimate agentic social media scheduling tool πŸ€–

feat: remove json stringify from cron payload

Nevo David5dc8bcfc01bf
diff --git a/apps/cron/src/tasks/check.stars.ts b/apps/cron/src/tasks/check.stars.ts
index c76bc00b9..5c5a9f291 100644
--- a/apps/cron/src/tasks/check.stars.ts
+++ b/apps/cron/src/tasks/check.stars.ts
@@ -13,11 +13,11 @@ export class CheckStars {
async checkStars() {
const allGitHubRepositories =
await this._starsService.getAllGitHubRepositories();
+
for (const repository of allGitHubRepositories) {
- this._workerServiceProducer.emit(
- 'check_stars',
- JSON.stringify({ payload: { login: repository.login } })
- );
+ this._workerServiceProducer.emit('check_stars', {
+ payload: { login: repository.login },
+ });
}
}
}
diff --git a/apps/workers/src/app/stars.controller.ts b/apps/workers/src/app/stars.controller.ts
index d70c7d8a7..5f73e1829 100644
--- a/apps/workers/src/app/stars.controller.ts
+++ b/apps/workers/src/app/stars.controller.ts
@@ -3,6 +3,7 @@ import { EventPattern, Transport } from '@nestjs/microservices';
import { JSDOM } from 'jsdom';
import { StarsService } from '@gitroom/nestjs-libraries/database/prisma/stars/stars.service';
import { TrendingService } from '@gitroom/nestjs-libraries/services/trending.service';
+import dayjs from 'dayjs';
@Controller()
export class StarsController {
@@ -33,6 +34,11 @@ export class StarsController {
data.login
);
+ if (dayjs(lastValue.date).format('YYYY-MM-DD') === dayjs().format('YYYY-MM-DD')) {
+ console.log('stars already synced for today');
+ return ;
+ }
+
const totalNewsStars = totalStars - (lastValue?.totalStars || 0);
const totalNewsForks = totalForks - (lastValue?.totalForks || 0);