From ecdec5912cbc70eef3274464ecde72d53675b4b9 Mon Sep 17 00:00:00 2001 From: hujiebin Date: Wed, 30 Aug 2023 17:52:03 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"feat:=20=E5=89=8D=E9=9D=A230=E4=B8=AA?= =?UTF-8?q?=E7=BE=A4"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 63842f2cbc4963c7cb22f15c420ddc684aec10d1. --- cv/group_cv/group.go | 185 +---------------------------- domain/cache/group_c/enter_room.go | 8 +- route/group_r/group_list.go | 4 +- 3 files changed, 10 insertions(+), 187 deletions(-) diff --git a/cv/group_cv/group.go b/cv/group_cv/group.go index d121a0f..3ded63f 100644 --- a/cv/group_cv/group.go +++ b/cv/group_cv/group.go @@ -251,7 +251,7 @@ type CvCountry struct { AreaCodeName *string `json:"areaShortName"` } -func BuildJoinedGroupInfo(myService *domain.Service, myUserId uint64, originGroupIds []string, pageSize, pageIndex int) ([]JoinedGroupInfo, int, error) { +func BuildJoinedGroupInfo(myService *domain.Service, myUserId uint64, originGroupIds []string, pageSize, pageIndex int, _roomEnterTime ...map[string]int64) ([]JoinedGroupInfo, int, error) { model := domain.CreateModel(myService.CtxAndDb) groupInfo, err := group_m.BatchGetGroupInfo(model, originGroupIds) @@ -321,6 +321,9 @@ func BuildJoinedGroupInfo(myService *domain.Service, myUserId uint64, originGrou if err != nil { return nil, 0, err } + if len(_roomEnterTime) > 0 { + roomEnterTime = _roomEnterTime[0] + } //model.Log.Infof("BuildJoinedGroupInfo, roomEnterTime: %v", roomEnterTime) // 排序优先级V8.0版本 @@ -445,186 +448,6 @@ func BuildJoinedGroupInfo(myService *domain.Service, myUserId uint64, originGrou return result, len(groupInfo), nil } -// 填充用户最近进房 -func BuildRecentGroupInfo(myService *domain.Service, myUserId uint64, originGroupIds []string, roomEnterTime map[string]int64) ([]JoinedGroupInfo, int, error) { - model := domain.CreateModel(myService.CtxAndDb) - - groupInfo, err := group_m.BatchGetGroupInfo(model, originGroupIds) - if err != nil { - return nil, 0, err - } - var groupIds []string - for _, groupId := range originGroupIds { - if group, ok := groupInfo[groupId]; ok { - if group.IsGameRoom == 0 { - groupIds = append(groupIds, groupId) - } - } - } - if len(groupIds) <= 0 { - return nil, 0, nil - } - - // 获取群组中上麦用户 - roomMicUserMap, err := group_m.BatchGetAllMicUser(model, groupIds) - if err != nil { - return nil, 0, err - } - uids := make([]uint64, 0) - micUsersMap := make(map[string][]uint64, 0) - for _, i := range groupInfo { - micUsersMap[i.ImGroupId] = make([]uint64, 0) - - if len(i.Password) <= 0 { - // 密码群不显示麦上头像 - u := roomMicUserMap[i.ImGroupId] - if len(u) >= 4 { - micUsersMap[i.ImGroupId] = u[0:4] - } else if len(u) > 0 { - micUsersMap[i.ImGroupId] = u - } - uids = append(uids, micUsersMap[i.ImGroupId]...) - } - } - - uids = utils.UniqueSliceUInt64(uids) - userTiny, err := user_cv.GetUserTinyMap(uids) - if err != nil { - return nil, 0, err - } - roomCount, err := group_m.BatchGetRoomCount(model, groupIds) - if err != nil { - return nil, 0, err - } - - countryInfo, err := res_c.GetCountryIconMap(model) - if err != nil { - return nil, 0, err - } - - supportLevels, err := group_s.NewGroupService(model.MyContext).GetWeekMaxSupportLevelMap() - if err != nil { - return nil, 0, err - } - - visitCount, err := group_m.BatchGetRoomVisitCount(model.Log, groupIds) - if err != nil { - return nil, 0, err - } - - // 排序优先级V8.0版本 - sort.Slice(groupIds, func(i, j int) bool { - gi := groupIds[i] - gj := groupIds[j] - return roomEnterTime[gi] > roomEnterTime[gj] || - roomEnterTime[gi] == roomEnterTime[gj] && visitCount[gj] > visitCount[gj] || - roomEnterTime[gi] == roomEnterTime[gj] && visitCount[gj] == visitCount[gj] && i >= j - }) - - result := make([]JoinedGroupInfo, 0) - owners := make([]uint64, 0) - for _, i := range groupIds { - owners = append(owners, groupInfo[i].Owner) - } - powerIds, powerNames, powerNameplates, powerGrades, err := group_power_cv.BatchGetGroupPower(model.Db, owners) - if err != nil { - return nil, 0, err - } - groupMedals, err := group_m.BatchGetMedals(model.Db, groupIds) - if err != nil { - return nil, 0, err - } - resMedal, err := res_m.MedalGetAllMap(model.Db) - if err != nil { - return nil, 0, err - } - - rr := rocket_m.RocketResult{} - maxStageMap, err := rr.GetMaxStage(model.Db, groupIds) - if err != nil { - return nil, 0, err - } - // 正在进行的游戏 - games := game_m.GetNotEndGamesMap(model) - - for _, i := range groupIds { - g := groupInfo[i] - micUsers := make([]user_cv.CvUserTiny, 0) - for _, j := range micUsersMap[i] { - micUsers = append(micUsers, userTiny[j]) - } - - var maxStage *uint16 = nil - if s, ok := maxStageMap[i]; ok { - maxStage = &s - } - - medals := make([]medal_cv.PicElement, 0) - // 补上房间流水勋章 - var pe *medal_cv.PicElement - _, pe, err = medal_cv.GetGroupConsumeMedal(model, i) - if err != nil { - model.Log.Infof("BuildJoinedGroupInfo: GetGroupConsumeMedal: %s", err.Error()) - } else if pe != nil { - medals = append(medals, medal_cv.PicElement{PicUrl: pe.PicUrl}) - } - // res_medal - if m, ok := groupMedals[i]; ok { - for _, j := range m { - mId := uint32(j) - if e, ok := resMedal[mId]; ok { - medals = append(medals, medal_cv.PicElement{ - PicUrl: e.PicUrl, - }) - } - } - } - - var password *string = nil - if len(g.Password) > 0 && g.Owner != myUserId { - emptyStr := "" - password = &emptyStr - } - - result = append(result, JoinedGroupInfo{ - PopularGroupInfo: PopularGroupInfo{ - GroupInfo: GroupInfo{ - GroupBasicInfo: GroupBasicInfo{ - GroupId: g.TxGroupId, - Name: g.Name, - Notification: g.Notification, - Introduction: g.Introduction, - FaceUrl: g.FaceUrl, - Code: g.Code, - CountryIcon: countryInfo[g.Country], - Password: password, - SupportLevel: supportLevels[i], - GroupInUserDuration: visitCount[i], - MicNumType: int(g.MicNumType), - GroupMedals: medals, - }, - HasOnMic: len(micUsers) > 0, - GroupPowerId: powerIds[g.Owner], - GroupPowerName: powerNames[g.Owner], - GroupPowerNameplate: powerNameplates[g.Owner], - GroupPower: GroupPower{ - Id: powerIds[g.Owner], - Name: powerNames[g.Owner], - Nameplate: powerNameplates[g.Owner], - Grade: powerGrades[g.Owner], - }, - }, - MicUsers: micUsers, - RoomUserCount: uint(roomCount[i]), - MaxStage: maxStage, - GameTypes: games[g.TxGroupId], - }, - LastEnterTime: roomEnterTime[i], - }) - } - return result, len(groupInfo), nil -} - func BuildPopularGroupInfo(model *domain.Model, myUserId uint64, groupInfo []*group_m.GroupInfo) ([]*PopularGroupInfo, error) { groupIds := make([]string, 0, len(groupInfo)) for _, v := range groupInfo { diff --git a/domain/cache/group_c/enter_room.go b/domain/cache/group_c/enter_room.go index 8d583ea..84c0b15 100644 --- a/domain/cache/group_c/enter_room.go +++ b/domain/cache/group_c/enter_room.go @@ -54,10 +54,10 @@ func GetUserRecentRooms(model *domain.Model, userId uint64, offset, limit int64) roomEnterTime = make(map[string]int64) userKey := group_k.GetUserEnterRoomUserKey(userId) res, err := model.Redis.ZRangeByScoreWithScores(model, userKey, &redis.ZRangeBy{ - Min: fmt.Sprintf("%d", time.Now().AddDate(0, -3, 0).Unix()), - Max: "+inf", - Offset: offset, - Count: limit, + Min: fmt.Sprintf("%d", time.Now().AddDate(0, -3, 0).Unix()), + Max: "+inf", + //Offset: offset, + //Count: limit, }).Result() if err != nil { return diff --git a/route/group_r/group_list.go b/route/group_r/group_list.go index 95722fa..d7ac7ba 100644 --- a/route/group_r/group_list.go +++ b/route/group_r/group_list.go @@ -719,7 +719,7 @@ func GetRecentGroup(c *gin.Context) (*mycontext.MyContext, error) { //if err != nil { // return myContext, err //} - rec, roomEnterTime := group_c.GetUserRecentRooms(model, userId, 0, 50) + rec, roomEnterTime := group_c.GetUserRecentRooms(model, userId, 0, 30) myGroups, err := group_m.FindGroupMapByOwner(model, userId) if err != nil { @@ -735,7 +735,7 @@ func GetRecentGroup(c *gin.Context) (*mycontext.MyContext, error) { } myService := domain.CreateService(myContext) - result, _, err := group_cv.BuildRecentGroupInfo(myService, userId, groupIds, roomEnterTime) + result, _, err := group_cv.BuildJoinedGroupInfo(myService, userId, groupIds, 30, 1, roomEnterTime) if err != nil { return myContext, err } -- 2.22.0