Skip to content

Commit 8f02192

Browse files
committed
Fix
1 parent f33725e commit 8f02192

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

src/gameserver/event-handler/crime-log-created.handler.ts

+21-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,22 @@ export class CrimeLogCreatedHandler
6060
@InjectRepository(PlayerBanEntity)
6161
private readonly playerBanRepository: Repository<PlayerBanEntity>,
6262
private readonly ebus: EventBus,
63-
) {}
63+
) {
64+
this.playerCrimeLogEntityRepository
65+
.find({
66+
where: {
67+
handled: false,
68+
},
69+
})
70+
.then((unhandled) =>
71+
Promise.all(
72+
unhandled.map((it) => this.handle(new CrimeLogCreatedEvent(it.id))),
73+
),
74+
)
75+
.then((proms) => {
76+
this.logger.log(`Initial cathing up in crimes finished, ${proms.length} crimes handled`)
77+
})
78+
}
6479

6580
async handle(event: CrimeLogCreatedEvent) {
6681
// ok, first we find last crime
@@ -88,11 +103,15 @@ export class CrimeLogCreatedHandler
88103

89104
const cumInterval = getPunishmentCumulativeInterval(thisCrime.crime);
90105

106+
this.logger.log(`Cumulative interval for crime is ${cumInterval}`)
107+
91108
const frequentCrimesCount = await this.playerCrimeLogEntityRepository
92109
.createQueryBuilder("pc")
93110
.select()
94111
.where("pc.steam_id = :sid", { sid: thisCrime.steam_id })
95-
.andWhere(`pc.created_at >= now() - ${cumInterval}::interval`) // interval here
112+
.andWhere(`pc.created_at >= now() - :cum_interval::interval`, {
113+
cum_interval: cumInterval
114+
}) // interval here
96115
.getMany();
97116

98117
// total crimes done within 24 hours

0 commit comments

Comments
 (0)