第一次提交

This commit is contained in:
dmy
2026-01-09 23:18:52 +08:00
commit d9105797f4
46 changed files with 15003 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
import { Module } from '@nestjs/common';
import { BidCrawlTask } from './tasks/bid-crawl.task';
import { CrawlerModule } from '../crawler/crawler.module';
import { BidsModule } from '../bids/bids.module';
@Module({
imports: [CrawlerModule, BidsModule],
providers: [BidCrawlTask],
})
export class TasksModule {}

View File

@@ -0,0 +1,26 @@
import { Injectable, Logger } from '@nestjs/common';
import { Cron, CronExpression } from '@nestjs/schedule';
import { BidCrawlerService } from '../../crawler/services/bid-crawler.service';
import { BidsService } from '../../bids/services/bid.service';
@Injectable()
export class BidCrawlTask {
private readonly logger = new Logger(BidCrawlTask.name);
constructor(
private crawlerService: BidCrawlerService,
private bidsService: BidsService,
) {}
@Cron(CronExpression.EVERY_30_MINUTES)
async handleCron() {
this.logger.debug('Scheduled crawl task started');
await this.crawlerService.crawlAll();
}
@Cron(CronExpression.EVERY_DAY_AT_MIDNIGHT)
async handleCleanup() {
this.logger.debug('Scheduled cleanup task started');
await this.bidsService.cleanOldData();
}
}