diff --git a/_const/redis_key/group_k/enter_room.go b/_const/redis_key/group_k/enter_room.go index 3e01264b2d6977596ea4eb863faefa0041172d1d..ac4ad9a5d6c27dd322c82e99fa6efa375cc08a02 100644 --- a/_const/redis_key/group_k/enter_room.go +++ b/_const/redis_key/group_k/enter_room.go @@ -9,7 +9,7 @@ import ( const ( UserEnterRoomPrefix = "uer:" UserEnterRoomUserKey = UserEnterRoomPrefix + "u:${user_id}" - UserEnterRoomGroupKey = UserEnterRoomPrefix + "g:${user_id}" + UserEnterRoomGroupKey = UserEnterRoomPrefix + "g:${group_id}" ) func GetUserEnterRoomUserKey(userId uint64) string { diff --git a/domain/cache/group_c/enter_room.go b/domain/cache/group_c/enter_room.go index 814ce8b0c0062473a5b3bae6240714edf3da68d3..e2fd116d01ac13911aad768cd755a3d07c3d609e 100644 --- a/domain/cache/group_c/enter_room.go +++ b/domain/cache/group_c/enter_room.go @@ -28,6 +28,7 @@ func ZAddUserEnterRoom(model *domain.Model, userId uint64, imGroupId string) { } // 获取最近房间访客 +// 15天 func GetLastRoomVisitors(model *domain.Model, imGroupId string) (userIds []uint64) { groupKey := group_k.GetUserEnterRoomGroupKey(imGroupId) res, err := model.Redis.ZRangeByScore(model, groupKey, &redis.ZRangeBy{ @@ -47,11 +48,12 @@ func GetLastRoomVisitors(model *domain.Model, imGroupId string) (userIds []uint6 } // 获取最近进入的房间 +// 3个月 func GetUserRecentRooms(model *domain.Model, userId uint64) (imGroupIds []string) { userKey := group_k.GetUserEnterRoomUserKey(userId) var err error imGroupIds, err = model.Redis.ZRangeByScore(model, userKey, &redis.ZRangeBy{ - Min: fmt.Sprintf("%d", time.Now().AddDate(0, 0, -15).Unix()), + Min: fmt.Sprintf("%d", time.Now().AddDate(0, -3, 0).Unix()), Max: "+inf", }).Result() if err != nil {