update file task send mail report
This commit is contained in:
parent
42e07dff55
commit
5c9ea7d721
|
|
@ -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
|
// Thực hiện gọi scrape vào lúc 8h59 (giờ ÚC) mỗi ngày
|
||||||
@Cron(CronExpression.EVERY_MINUTE)
|
// @Cron(CronExpression.EVERY_MINUTE)
|
||||||
// @Cron('59 5 * * *')
|
@Cron('59 5 * * *')
|
||||||
async handleScraps() {
|
async handleScraps() {
|
||||||
const processName = 'scrape-data-keyword';
|
const processName = 'scrape-data-keyword';
|
||||||
// await this.runProcessAndSendReport(processName);
|
// await this.runProcessAndSendReport(processName);
|
||||||
|
|
||||||
// await this.runProcess(processName);
|
await this.runProcess(processName);
|
||||||
|
|
||||||
const ramKeywords = ['DDR4', 'DDR5', 'DDR4|', 'DDR5|'];
|
const ramKeywords = ['DDR4', 'DDR5', 'DDR4|', 'DDR5|'];
|
||||||
|
|
||||||
|
|
@ -216,7 +246,7 @@ export class TasksService {
|
||||||
data: products,
|
data: products,
|
||||||
keywords: productConfigs.map((item) => ({
|
keywords: productConfigs.map((item) => ({
|
||||||
source: extractDomainSmart(item.search_url),
|
source: extractDomainSmart(item.search_url),
|
||||||
keywords: item.keywords,
|
keywords: this.filterKeywords(item.keywords, ramKeywords),
|
||||||
})),
|
})),
|
||||||
subject: 'Auction Items Matching Your Keywords',
|
subject: 'Auction Items Matching Your Keywords',
|
||||||
});
|
});
|
||||||
|
|
@ -225,7 +255,7 @@ export class TasksService {
|
||||||
data: rams,
|
data: rams,
|
||||||
keywords: ramConfigs.map((item) => ({
|
keywords: ramConfigs.map((item) => ({
|
||||||
source: extractDomainSmart(item.search_url),
|
source: extractDomainSmart(item.search_url),
|
||||||
keywords: item.keywords,
|
keywords: this.keepKeywords(item.keywords, ramKeywords),
|
||||||
})),
|
})),
|
||||||
subject: 'DDR4, DDR5 Item Report',
|
subject: 'DDR4, DDR5 Item Report',
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue