update file task send mail report

This commit is contained in:
Admin 2026-01-30 13:25:07 +07:00
parent 42e07dff55
commit 5c9ea7d721
1 changed files with 35 additions and 5 deletions

View File

@ -152,14 +152,44 @@ export class TasksService {
}
}
filterKeywords(input: string, blacklist: string[]): string {
if (!input) return '';
const blacklistLower = blacklist.map((k) => k.toLowerCase());
return input
.split(',')
.map((item) => item.trim())
.filter((item) => {
const lower = item.toLowerCase();
return !blacklistLower.some((b) => lower.includes(b));
})
.join(', ');
}
keepKeywords(input: string, whitelist: string[]): string {
if (!input) return '';
const whitelistLower = whitelist.map((k) => k.toLowerCase());
return input
.split(',')
.map((item) => item.trim())
.filter((item) => {
const lower = item.toLowerCase();
return whitelistLower.some((w) => lower.includes(w));
})
.join(', ');
}
// Thực hiện gọi scrape vào lúc 8h59 (giờ ÚC) mỗi ngày
@Cron(CronExpression.EVERY_MINUTE)
// @Cron('59 5 * * *')
// @Cron(CronExpression.EVERY_MINUTE)
@Cron('59 5 * * *')
async handleScraps() {
const processName = 'scrape-data-keyword';
// await this.runProcessAndSendReport(processName);
// await this.runProcess(processName);
await this.runProcess(processName);
const ramKeywords = ['DDR4', 'DDR5', 'DDR4|', 'DDR5|'];
@ -216,7 +246,7 @@ export class TasksService {
data: products,
keywords: productConfigs.map((item) => ({
source: extractDomainSmart(item.search_url),
keywords: item.keywords,
keywords: this.filterKeywords(item.keywords, ramKeywords),
})),
subject: 'Auction Items Matching Your Keywords',
});
@ -225,7 +255,7 @@ export class TasksService {
data: rams,
keywords: ramConfigs.map((item) => ({
source: extractDomainSmart(item.search_url),
keywords: item.keywords,
keywords: this.keepKeywords(item.keywords, ramKeywords),
})),
subject: 'DDR4, DDR5 Item Report',
});