@@ -10,13 +10,12 @@ export class ActiveUserService implements OnModuleInit {
1010 onModuleInit ( ) {
1111 this . countUp ( ) ;
1212 this . countDown ( ) ;
13- this . applyToRedis ( ) ;
1413 }
1514
1615 private countUp ( ) {
1716 const channel = '__keyspace@1__:APPEND' ;
18- this . redisService . subscribeActiveUser ( channel , async ( sid ) => {
19- const pod = await this . redisService . hgetSession ( sid , 'pod' ) ;
17+ this . redisService . subscribeActiveUser ( channel , async ( sessionId ) => {
18+ const pod = await this . redisService . hgetSession ( sessionId , 'pod' ) ;
2019
2120 const currentCount = this . activeUserVariation . get ( pod ) ?? 0 ;
2221 this . activeUserVariation . set ( pod , currentCount + 1 ) ;
@@ -25,16 +24,16 @@ export class ActiveUserService implements OnModuleInit {
2524
2625 private countDown ( ) {
2726 const channel = '__keyspace@1__:EXPIRE' ;
28- this . redisService . subscribeActiveUser ( channel , async ( sid ) => {
29- const pod = await this . redisService . hgetSession ( sid , 'pod' ) ;
27+ this . redisService . subscribeActiveUser ( channel , async ( sessionId ) => {
28+ const pod = await this . redisService . hgetSession ( sessionId , 'pod' ) ;
3029
3130 const currentCount = this . activeUserVariation . get ( pod ) ?? 0 ;
3231 this . activeUserVariation . set ( pod , currentCount - 1 ) ;
3332 } ) ;
3433 }
3534
3635 @Cron ( CronExpression . EVERY_MINUTE )
37- private async applyToRedis ( ) {
36+ async applyToRedis ( ) {
3837 for ( const [ pod , variation ] of this . activeUserVariation . entries ( ) ) {
3938 const count = await this . redisService . hgetPod ( pod , 'activeUser' ) ;
4039 const newCount = ( count ? parseInt ( count , 10 ) : 0 ) + variation ;
0 commit comments