Skip to content

Commit

Permalink
✨ Implement tip randomization task
Browse files Browse the repository at this point in the history
  • Loading branch information
Xen0Xys committed Jan 6, 2024
1 parent 75374a4 commit b41bc44
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/tasks/tasks.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import {UserCleanupTask} from "./user-cleanup.task";
import {SecretsRotationTask} from "./secrets-rotation.task";
import {UsersModule} from "../users/users.module";
import {SecretsModule} from "../secrets/secrets.module";
import {TipsModule} from "../tips/tips.module";
import {TipsRandomizingTask} from "./tips-randomizing.task";

@Module({
providers: [TokenCleanupTask, UserCleanupTask, SecretsRotationTask],
imports: [ServicesModule, UsersModule, SecretsModule],
providers: [TokenCleanupTask, UserCleanupTask, SecretsRotationTask, TipsRandomizingTask],
imports: [ServicesModule, UsersModule, SecretsModule, TipsModule],
})
export class TasksModule{}
21 changes: 21 additions & 0 deletions src/tasks/tips-randomizing.task.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import {Injectable, Logger} from "@nestjs/common";
import {Cron} from "@nestjs/schedule";
import {TipsService} from "../tips/tips.service";


@Injectable()
export class TipsRandomizingTask{

private readonly logger = new Logger(TipsRandomizingTask.name);

constructor(
private readonly tipsService: TipsService,
){}

@Cron("0 0 0 1 * *")
async handleCron(){
this.logger.log("Randomizing tips order");
await this.tipsService.randomizeTipsOrder();
this.logger.log("Tips order randomized");
}
}

0 comments on commit b41bc44

Please sign in to comment.