Commit 6bfa03f0 authored by chenweijian's avatar chenweijian

trtc导量

parent 679e05fd
...@@ -36,6 +36,12 @@ func GetRandomImProvider(model *domain.Model) group_e.GroupProvider { ...@@ -36,6 +36,12 @@ func GetRandomImProvider(model *domain.Model) group_e.GroupProvider {
model.Log.Errorf("GetRandomImProvider err:%v", err) model.Log.Errorf("GetRandomImProvider err:%v", err)
return res return res
} }
conf := GetRandomGroupImConf(confList)
return conf.Provider
}
func GetRandomGroupImConf(confList []*GroupIm) *GroupIm {
var res *GroupIm
var max int var max int
for i, v := range confList { for i, v := range confList {
if v.Prob > 0 { if v.Prob > 0 {
...@@ -48,7 +54,7 @@ func GetRandomImProvider(model *domain.Model) group_e.GroupProvider { ...@@ -48,7 +54,7 @@ func GetRandomImProvider(model *domain.Model) group_e.GroupProvider {
randNum := rand.Intn(max) randNum := rand.Intn(max)
for _, v := range confList { for _, v := range confList {
if v.StartIdx <= randNum && randNum < v.EndIdx { if v.StartIdx <= randNum && randNum < v.EndIdx {
res = v.Provider res = v
} }
} }
return res return res
......
...@@ -49,3 +49,23 @@ func TestDoCalcGroupPowerMonthRankActbufa(t *testing.T) { ...@@ -49,3 +49,23 @@ func TestDoCalcGroupPowerMonthRankActbufa(t *testing.T) {
beginDate, endDate := _now.BeginningOfMonth().Format("2006-01-02"), _now.EndOfMonth().Format("2006-01-02") beginDate, endDate := _now.BeginningOfMonth().Format("2006-01-02"), _now.EndOfMonth().Format("2006-01-02")
_ = group_power_s.BufaDoCalcGroupPowerMonthRankAct(domain.CreateModelNil(), calcMonth, beginDate, endDate, starDate) _ = 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)
}
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