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
6bfa03f0
Commit
6bfa03f0
authored
May 23, 2023
by
chenweijian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
trtc导量
parent
679e05fd
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
1 deletion
+27
-1
group_im.go
domain/model/group_m/group_im.go
+7
-1
group_power_test.go
test/group_power_test.go
+20
-0
No files found.
domain/model/group_m/group_im.go
View file @
6bfa03f0
...
...
@@ -36,6 +36,12 @@ func GetRandomImProvider(model *domain.Model) group_e.GroupProvider {
model
.
Log
.
Errorf
(
"GetRandomImProvider err:%v"
,
err
)
return
res
}
conf
:=
GetRandomGroupImConf
(
confList
)
return
conf
.
Provider
}
func
GetRandomGroupImConf
(
confList
[]
*
GroupIm
)
*
GroupIm
{
var
res
*
GroupIm
var
max
int
for
i
,
v
:=
range
confList
{
if
v
.
Prob
>
0
{
...
...
@@ -48,7 +54,7 @@ func GetRandomImProvider(model *domain.Model) group_e.GroupProvider {
randNum
:=
rand
.
Intn
(
max
)
for
_
,
v
:=
range
confList
{
if
v
.
StartIdx
<=
randNum
&&
randNum
<
v
.
EndIdx
{
res
=
v
.
Provider
res
=
v
}
}
return
res
...
...
test/group_power_test.go
View file @
6bfa03f0
...
...
@@ -49,3 +49,23 @@ func TestDoCalcGroupPowerMonthRankActbufa(t *testing.T) {
beginDate
,
endDate
:=
_now
.
BeginningOfMonth
()
.
Format
(
"2006-01-02"
),
_now
.
EndOfMonth
()
.
Format
(
"2006-01-02"
)
_
=
group_power_s
.
BufaDoCalcGroupPowerMonthRankAct
(
domain
.
CreateModelNil
(),
calcMonth
,
beginDate
,
endDate
,
starDate
)
}
func
TestGetRandomImProvider
(
t
*
testing
.
T
)
{
var
times0
,
times1
int
model
:=
domain
.
CreateModelNil
()
confList
,
err
:=
group_m
.
GetGroupImConf
(
model
)
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"GetRandomImProvider err:%v"
,
err
)
return
}
for
i
:=
0
;
i
<
1000000
;
i
++
{
conf
:=
group_m
.
GetRandomGroupImConf
(
confList
)
if
conf
.
Provider
==
0
{
times0
+=
1
}
else
if
conf
.
Provider
==
1
{
times1
+=
1
}
}
fmt
.
Printf
(
"true--------------times0:%v
\n
"
,
times0
)
fmt
.
Printf
(
"true--------------times1:%v
\n
"
,
times1
)
}
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