diff --git a/domain/cache/group_c/enter_room.go b/domain/cache/group_c/enter_room.go index e2fd116d01ac13911aad768cd755a3d07c3d609e..ff8631f74d07ef41db1ff9d3ee7dd03994e80aa4 100644 --- a/domain/cache/group_c/enter_room.go +++ b/domain/cache/group_c/enter_room.go @@ -66,8 +66,10 @@ func GetUserRecentRooms(model *domain.Model, userId uint64) (imGroupIds []string // 15天前访问的 func RemoveRoomVisitors(model *domain.Model, imGroupId string) { groupKey := group_k.GetUserEnterRoomGroupKey(imGroupId) - err := model.Redis.ZRemRangeByScore(model, groupKey, "-inf", fmt.Sprintf("%d", time.Now().AddDate(0, 0, -15).Unix())).Err() + n, err := model.Redis.ZRemRangeByScore(model, groupKey, "-inf", fmt.Sprintf("%d", time.Now().AddDate(0, 0, -15).Unix())).Result() if err != nil { model.Log.Errorf("RemoveRoomVisitors fail:%v", err) + } else { + model.Log.Infof("RemoveRoomVisitors key:%v,n:%v", groupKey, n) } } diff --git a/route/group_r/group_list.go b/route/group_r/group_list.go index 8a21ddfa5e190ced752da6b5dc766e6823750eb0..cebe0a6c86225a5b93bbceb4d9a38583ae0b9520 100644 --- a/route/group_r/group_list.go +++ b/route/group_r/group_list.go @@ -973,6 +973,8 @@ func GetGroupVisitors(c *gin.Context) (*mycontext.MyContext, error) { } } resp.ResponseOk(c, result) + // 清理15天之前的访客 + group_c.RemoveRoomVisitors(model, groupId) return myContext, nil } diff --git a/test/user_test.go b/test/user_test.go index 55124d9c53c4d87c9e9a494d970244615078980e..b4310b7432bdb10acb303a19742a33a31f447bdb 100644 --- a/test/user_test.go +++ b/test/user_test.go @@ -2,6 +2,7 @@ package test import ( "git.hilo.cn/hilo-common/domain" + "hilo-group/domain/cache/group_c" "hilo-group/domain/model/user_m" "testing" ) @@ -23,3 +24,7 @@ func TestGetUserVipMap(t *testing.T) { res, err := user_m.BatchGetVips(userIds) t.Logf("%v-%v", res, err) } + +func TestRemoveRoomVisit(t *testing.T) { + group_c.RemoveRoomVisitors(domain.CreateModelNil(), "HTGS#a47478749") +}