Commit ecdec591 authored by hujiebin's avatar hujiebin

Revert "feat: 前面30个群"

This reverts commit 63842f2c.
parent 63842f2c
...@@ -251,7 +251,7 @@ type CvCountry struct { ...@@ -251,7 +251,7 @@ type CvCountry struct {
AreaCodeName *string `json:"areaShortName"` 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) model := domain.CreateModel(myService.CtxAndDb)
groupInfo, err := group_m.BatchGetGroupInfo(model, originGroupIds) groupInfo, err := group_m.BatchGetGroupInfo(model, originGroupIds)
...@@ -321,6 +321,9 @@ func BuildJoinedGroupInfo(myService *domain.Service, myUserId uint64, originGrou ...@@ -321,6 +321,9 @@ func BuildJoinedGroupInfo(myService *domain.Service, myUserId uint64, originGrou
if err != nil { if err != nil {
return nil, 0, err return nil, 0, err
} }
if len(_roomEnterTime) > 0 {
roomEnterTime = _roomEnterTime[0]
}
//model.Log.Infof("BuildJoinedGroupInfo, roomEnterTime: %v", roomEnterTime) //model.Log.Infof("BuildJoinedGroupInfo, roomEnterTime: %v", roomEnterTime)
// 排序优先级V8.0版本 // 排序优先级V8.0版本
...@@ -445,186 +448,6 @@ func BuildJoinedGroupInfo(myService *domain.Service, myUserId uint64, originGrou ...@@ -445,186 +448,6 @@ func BuildJoinedGroupInfo(myService *domain.Service, myUserId uint64, originGrou
return result, len(groupInfo), nil 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) { func BuildPopularGroupInfo(model *domain.Model, myUserId uint64, groupInfo []*group_m.GroupInfo) ([]*PopularGroupInfo, error) {
groupIds := make([]string, 0, len(groupInfo)) groupIds := make([]string, 0, len(groupInfo))
for _, v := range groupInfo { for _, v := range groupInfo {
......
...@@ -56,8 +56,8 @@ func GetUserRecentRooms(model *domain.Model, userId uint64, offset, limit int64) ...@@ -56,8 +56,8 @@ func GetUserRecentRooms(model *domain.Model, userId uint64, offset, limit int64)
res, err := model.Redis.ZRangeByScoreWithScores(model, userKey, &redis.ZRangeBy{ res, err := model.Redis.ZRangeByScoreWithScores(model, userKey, &redis.ZRangeBy{
Min: fmt.Sprintf("%d", time.Now().AddDate(0, -3, 0).Unix()), Min: fmt.Sprintf("%d", time.Now().AddDate(0, -3, 0).Unix()),
Max: "+inf", Max: "+inf",
Offset: offset, //Offset: offset,
Count: limit, //Count: limit,
}).Result() }).Result()
if err != nil { if err != nil {
return return
......
...@@ -719,7 +719,7 @@ func GetRecentGroup(c *gin.Context) (*mycontext.MyContext, error) { ...@@ -719,7 +719,7 @@ func GetRecentGroup(c *gin.Context) (*mycontext.MyContext, error) {
//if err != nil { //if err != nil {
// return myContext, err // 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) myGroups, err := group_m.FindGroupMapByOwner(model, userId)
if err != nil { if err != nil {
...@@ -735,7 +735,7 @@ func GetRecentGroup(c *gin.Context) (*mycontext.MyContext, error) { ...@@ -735,7 +735,7 @@ func GetRecentGroup(c *gin.Context) (*mycontext.MyContext, error) {
} }
myService := domain.CreateService(myContext) 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 { if err != nil {
return myContext, err return myContext, err
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment