Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hilo-group
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hujiebin
hilo-group
Commits
7998a65a
Commit
7998a65a
authored
Aug 28, 2023
by
chenweijian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
群组优化
parent
f34d8846
This commit is part of merge request
!73
. Comments created here will be created in the context of that merge request.
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
3 deletions
+41
-3
group_list.go
cron/group_cron/group_list.go
+2
-2
mic.go
domain/model/group_m/mic.go
+34
-0
group_list.go
route/group_r/group_list.go
+5
-1
No files found.
cron/group_cron/group_list.go
Edit
View file @
7998a65a
...
@@ -10,7 +10,7 @@ import (
...
@@ -10,7 +10,7 @@ import (
func
GroupCountryListSort
()
{
func
GroupCountryListSort
()
{
// 常用国家-每15分钟计算国家房间列表排序 /v1/imGroup/country [get] 接口
// 常用国家-每15分钟计算国家房间列表排序 /v1/imGroup/country [get] 接口
spec
:=
"0 */
15
* * * ?"
spec
:=
"0 */
2
* * * ?"
c
:=
cron
.
New
()
c
:=
cron
.
New
()
_
=
c
.
AddFunc
(
spec
,
func
()
{
_
=
c
.
AddFunc
(
spec
,
func
()
{
var
model
=
domain
.
CreateModelNil
()
var
model
=
domain
.
CreateModelNil
()
...
@@ -18,7 +18,7 @@ func GroupCountryListSort() {
...
@@ -18,7 +18,7 @@ func GroupCountryListSort() {
})
})
// 非常用国家-每60分钟计算国家房间列表排序 /v1/imGroup/country [get] 接口
// 非常用国家-每60分钟计算国家房间列表排序 /v1/imGroup/country [get] 接口
spec2
:=
"0
15
* * * ?"
spec2
:=
"0
28
* * * ?"
_
=
c
.
AddFunc
(
spec2
,
func
()
{
_
=
c
.
AddFunc
(
spec2
,
func
()
{
var
model
=
domain
.
CreateModelNil
()
var
model
=
domain
.
CreateModelNil
()
group_s
.
SortGroupNotCommonCountryList
(
model
)
group_s
.
SortGroupNotCommonCountryList
(
model
)
...
...
domain/model/group_m/mic.go
Edit
View file @
7998a65a
...
@@ -920,6 +920,40 @@ func GetMicHasInGroupNum(model *domain.Model) (map[string]int64, error) {
...
@@ -920,6 +920,40 @@ func GetMicHasInGroupNum(model *domain.Model) (map[string]int64, error) {
return
resultGroupUuids
,
nil
return
resultGroupUuids
,
nil
}
}
// 获取麦上人数
func
GetMicHasInGroupNumByList
(
model
*
domain
.
Model
,
groupIds
[]
string
)
(
map
[
string
]
int64
,
error
)
{
resultGroupUuids
:=
make
(
map
[
string
]
int64
,
len
(
groupIds
))
micHasInKey
:=
redis_key
.
GetPrefixGroupMicHasIn
()
for
_
,
group
:=
range
groupIds
{
isMem
,
err
:=
redisCli
.
GetRedis
()
.
SIsMember
(
context
.
Background
(),
micHasInKey
,
group
)
.
Result
()
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"GetMicHasInGroupNumByList err:%v"
,
err
)
return
nil
,
myerr
.
WrapErr
(
err
)
}
if
isMem
{
s
:=
strings
.
Replace
(
micHasInScript
,
"{key}"
,
micHasInKey
,
-
1
)
s
=
strings
.
Replace
(
s
,
"{remKey}"
,
group
,
-
1
)
for
i
:=
1
;
i
<=
MaxMicNum
;
i
++
{
s
=
strings
.
Replace
(
s
,
"{key"
+
strconv
.
Itoa
(
i
)
+
"}"
,
redis_key
.
GetPrefixGroupMicUser
(
group
,
i
),
-
1
)
}
//r, err := redis2.NewScript(s).Run(context.Background(), redisCli.GetRedis(), []string{}).Result()
sha1
,
err
:=
model
.
Redis
.
ScriptLoad
(
model
,
s
)
.
Result
()
if
err
!=
nil
{
return
nil
,
myerr
.
WrapErr
(
err
)
}
micNum
,
err
:=
model
.
Redis
.
EvalSha
(
model
,
sha1
,
nil
,
nil
)
.
Int64
()
if
err
!=
nil
{
return
nil
,
myerr
.
WrapErr
(
err
)
}
//d := r.(int64)
if
micNum
>
0
{
resultGroupUuids
[
group
]
=
micNum
}
}
}
return
resultGroupUuids
,
nil
}
//获取麦上有人的群组&&麦上的数(有时间性,目前是24小时)
//获取麦上有人的群组&&麦上的数(有时间性,目前是24小时)
func
GetMicHasInPeriodGroupUser
()
(
map
[
string
][]
uint64
,
error
)
{
func
GetMicHasInPeriodGroupUser
()
(
map
[
string
][]
uint64
,
error
)
{
//清理超过12小时的
//清理超过12小时的
...
...
route/group_r/group_list.go
Edit
View file @
7998a65a
...
@@ -1564,6 +1564,11 @@ func GetGroupByCountryV2(c *gin.Context) (*mycontext.MyContext, error) {
...
@@ -1564,6 +1564,11 @@ func GetGroupByCountryV2(c *gin.Context) (*mycontext.MyContext, error) {
model
.
Log
.
Errorf
(
"GetGroupByCountry err:%v"
,
err
)
model
.
Log
.
Errorf
(
"GetGroupByCountry err:%v"
,
err
)
return
myContext
,
err
return
myContext
,
err
}
}
// 获取麦上人数
micGroupNum
,
err
:=
group_m
.
GetMicHasInGroupNum
(
model
)
if
err
!=
nil
{
return
myContext
,
err
}
for
_
,
i
:=
range
hotGroupList
{
for
_
,
i
:=
range
hotGroupList
{
var
maxStage
*
uint16
=
nil
var
maxStage
*
uint16
=
nil
...
@@ -1630,7 +1635,6 @@ func GetGroupByCountryV2(c *gin.Context) (*mycontext.MyContext, error) {
...
@@ -1630,7 +1635,6 @@ func GetGroupByCountryV2(c *gin.Context) (*mycontext.MyContext, error) {
})
})
}
}
model
.
Log
.
Infof
(
"GetGroupByCountry cost6:%v"
,
time
.
Now
()
.
Sub
(
beginTime
))
resp
.
ResponsePageOk
(
c
,
result
,
uint
(
total
),
pageIndex
)
resp
.
ResponsePageOk
(
c
,
result
,
uint
(
total
),
pageIndex
)
return
myContext
,
nil
return
myContext
,
nil
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment