Merge pull request 'update file task send mail report' (#112) from main into staging
Reviewed-on: #112
This commit is contained in:
commit
840004ab11
|
|
@ -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',
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue