feat: remove json stringify from cron payload
This commit is contained in:
parent
0d3582c99a
commit
5dc8bcfc01
|
|
@ -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 },
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue