Commit 2cc919d6 authored by hujiebin's avatar hujiebin

refact:优化遍历麦位

parent 323f59ee
......@@ -21,7 +21,7 @@ func OnMicCheck() {
}
for _, groupId := range groupIds {
//遍历每个麦位
for i := 1; i <= 30; i++ {
for i := 1; i <= group_m.MaxMicNum; i++ {
micUser, err := group_m.GetMicUser(model, groupId, i)
if err != nil {
model.Log.Errorf("cron micIn group_m.GetMicUser err:%v", err)
......
......@@ -432,7 +432,7 @@ func GetMicUserByExternalId(model *domain.Model, externalId string) (*MicUser, e
//麦位上没人,返回nil
func GetMicUser(model *domain.Model, groupUuid string, i int) (*MicUser, error) {
if i < 1 || i > 30 {
if i < 1 || i > MaxMicNum {
return nil, myerr.NewSysErrorF("麦序不对,不在范围值内 i:%v", i)
}
str, err := redisCli.GetRedis().Get(context.Background(), redis_key.GetPrefixGroupMicUser(groupUuid, i)).Result()
......
......@@ -843,6 +843,7 @@ func GetMicHasInGroups() ([]string, error) {
if err != nil {
return nil, myerr.WrapErr(err)
}
return groupUuids, nil // 不需要下面的逐个麦位的判断了
//
resultGroupUuids := make([]string, 0, len(groupUuids))
//循环lua判断是否, 最后的保证,(猜想:真正麦上有人的群没有很多)
......
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