forked from StellarSplit/StellarSplit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettlement.module.ts
More file actions
62 lines (58 loc) · 1.79 KB
/
Copy pathsettlement.module.ts
File metadata and controls
62 lines (58 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import { Module, OnModuleInit } from "@nestjs/common";
import { TypeOrmModule } from "@nestjs/typeorm";
import { BullModule, InjectQueue } from "@nestjs/bull";
import { Queue } from "bull";
import { SettlementSuggestion } from "./entities/settlement-suggestions.entity";
import { SettlementStep } from "./entities/settlement-step.entity";
import { SettlementController } from "./settlement.controller";
import { SettlementService } from "./settlement.service";
import { SuggestionEngineService } from "./suggestion-engine.service";
import { StellarPayloadService } from "./stellar-payload.service";
import { SettlementProcessor } from "./settlement.processor";
import { Participant } from "@/entities/participant.entity";
import { User } from "../entities/user.entity";
import { StellarModule } from "../stellar/stellar.module";
import { EmailModule } from "../email/email.module";
@Module({
imports: [
TypeOrmModule.forFeature([
SettlementSuggestion,
SettlementStep,
Participant,
User,
]),
BullModule.registerQueue({ name: "settlement-tasks" }),
StellarModule,
EmailModule,
],
controllers: [SettlementController],
providers: [
SettlementService,
SuggestionEngineService,
StellarPayloadService,
SettlementProcessor,
],
})
export class SettlementModule implements OnModuleInit {
constructor(
@InjectQueue("settlement-tasks") private settlementQueue: Queue,
) {}
async onModuleInit() {
await this.settlementQueue.add(
"send-weekly-settlement-digest",
{},
{
repeat: { cron: "0 0 * * 0" },
jobId: "weekly_digest",
},
);
await this.settlementQueue.add(
"cleanup-expired-suggestions",
{},
{
repeat: { cron: "0 * * * *" },
jobId: "hourly_cleanup",
},
);
}
}