Skip to content

Commit

Permalink
✨ Implement auto webtoon update at 5pm every day
Browse files Browse the repository at this point in the history
  • Loading branch information
Xen0Xys committed May 28, 2024
1 parent 42a99a8 commit 7655868
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {AdminModule} from "./modules/webtoon/admin/admin.module";
import {ThrottlerGuard, ThrottlerModule} from "@nestjs/throttler";
import {APP_GUARD} from "@nestjs/core";
import {MigrationModule} from "./modules/webtoon/migration/migration.module";
import {ScheduleModule} from "@nestjs/schedule";

@Module({
imports: [
Expand All @@ -14,6 +15,7 @@ import {MigrationModule} from "./modules/webtoon/migration/migration.module";
ttl: 60000,
limit: 50,
}]),
ScheduleModule.forRoot(),
TaskModule,
WebtoonModule,
AdminModule,
Expand Down
7 changes: 4 additions & 3 deletions src/modules/task/task.module.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import {Module} from "@nestjs/common";
import {WebtoonUpdateTask} from "./webtoon_update.task";
import {WebtoonModule} from "../webtoon/webtoon/webtoon.module";

@Module({
imports: [],
controllers: [],
providers: [],
providers: [WebtoonUpdateTask],
imports: [WebtoonModule]
})
export class TaskModule{}
18 changes: 18 additions & 0 deletions src/modules/task/webtoon_update.task.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import {Injectable} from "@nestjs/common";
import {Cron} from "@nestjs/schedule";
import {DownloadManagerService} from "../webtoon/webtoon/download-manager.service";


@Injectable()
export class WebtoonUpdateTask{

constructor(
private readonly downloadManagerService: DownloadManagerService
){}

@Cron("0 0 17 * * *")
async handleCron(){
// Called every day at 17:00
this.downloadManagerService.updateAllWebtoons();
}
}

0 comments on commit 7655868

Please sign in to comment.