File tree 1 file changed +21
-2
lines changed
src/gameserver/event-handler
1 file changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -60,7 +60,22 @@ export class CrimeLogCreatedHandler
60
60
@InjectRepository ( PlayerBanEntity )
61
61
private readonly playerBanRepository : Repository < PlayerBanEntity > ,
62
62
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
+ }
64
79
65
80
async handle ( event : CrimeLogCreatedEvent ) {
66
81
// ok, first we find last crime
@@ -88,11 +103,15 @@ export class CrimeLogCreatedHandler
88
103
89
104
const cumInterval = getPunishmentCumulativeInterval ( thisCrime . crime ) ;
90
105
106
+ this . logger . log ( `Cumulative interval for crime is ${ cumInterval } ` )
107
+
91
108
const frequentCrimesCount = await this . playerCrimeLogEntityRepository
92
109
. createQueryBuilder ( "pc" )
93
110
. select ( )
94
111
. 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
96
115
. getMany ( ) ;
97
116
98
117
// total crimes done within 24 hours
You can’t perform that action at this time.
0 commit comments