import { Injectable, Logger } from '@nestjs/common'; import { Cron, CronExpression } from '@nestjs/schedule'; import { IsNull, Not } from 'typeorm'; import { ScrapConfigsService } from './scrap-config.service'; @Injectable() export class TasksService { private readonly logger = new Logger(TasksService.name); constructor(private readonly scrapConfigsService: ScrapConfigsService) {} @Cron(CronExpression.EVERY_MINUTE) async handleScraps() { // const scrapConfigs = await this.scrapConfigsService.scrapConfigRepo.find({ // where: { // search_url: Not(IsNull()), // keywords: Not(IsNull()), // }, // relations: { // web_bid: true, // }, // }); // const models = this.scrapConfigsService.scrapModels(scrapConfigs); // await Promise.allSettled(models.map(async (item) => await item.action())); } }