group_power_test.go 2.66 KB
Newer Older
hujiebin's avatar
hujiebin committed
1 2 3
package test

import (
chenweijian's avatar
chenweijian committed
4
	"fmt"
hujiebin's avatar
hujiebin committed
5
	"git.hilo.cn/hilo-common/domain"
hujiebin's avatar
hujiebin committed
6
	"git.hilo.cn/hilo-common/resource/redisCli"
chenweijian's avatar
chenweijian committed
7 8
	"git.hilo.cn/hilo-common/utils"
	"github.com/jinzhu/now"
hujiebin's avatar
hujiebin committed
9
	"hilo-group/domain/cache/groupPower_c"
hujiebin's avatar
hujiebin committed
10
	"hilo-group/domain/model/groupPower_m"
chenweijian's avatar
chenweijian committed
11
	"hilo-group/domain/model/group_m"
chenweijian's avatar
chenweijian committed
12
	"hilo-group/domain/service/group_power_s"
hujiebin's avatar
hujiebin committed
13
	"testing"
chenweijian's avatar
chenweijian committed
14
	"time"
hujiebin's avatar
hujiebin committed
15 16 17
)

func TestGetAllGroupPowerOwner(t *testing.T) {
chenweijian's avatar
chenweijian committed
18
	owners, _, err := groupPower_m.BatchGetAllGroupPowerUsers(domain.CreateModelNil(), 1, 1)
hujiebin's avatar
hujiebin committed
19 20
	println(owners, err)
}
21 22 23

func TestGetGroupPowerMonthStartTop1(t *testing.T) {
	res, err := groupPower_m.GetGroupPowerMonthStartTop1(domain.CreateModelNil(), 250)
chenweijian's avatar
chenweijian committed
24 25 26 27 28 29 30
	println(res, err)
}

func TestIsUseTRTC(t *testing.T) {
	if group_m.IsUseTRTC(domain.CreateModelNil(), "@TGS#3I57DMRIB") {
		fmt.Println("true--------------")
	}
31
}
chenweijian's avatar
chenweijian committed
32 33

func TestIsMaxMember(t *testing.T) {
chenweijian's avatar
chenweijian committed
34
	//maxNum := group_power_s.GetGroupPowerMaxMemberNum(domain.CreateModelNil(), 263, grade.Grade)
chenweijian's avatar
chenweijian committed
35 36
	fmt.Println("true--------------")
}
chenweijian's avatar
chenweijian committed
37 38 39 40 41 42

func TestDoCalcGroupPowerMonthRankAct(t *testing.T) {
	lastDayTime := time.Now().AddDate(0, 0, -1)
	_now := now.New(lastDayTime)
	calcMonth := _now.BeginningOfMonth().Format(utils.MONTH_FORMAT)
	beginDate, endDate := _now.BeginningOfMonth().Format("2006-01-02"), _now.EndOfMonth().Format("2006-01-02")
chenweijian's avatar
chenweijian committed
43 44 45 46 47 48 49 50 51 52
	_ = group_power_s.DoCalcGroupPowerMonthRankAct(domain.CreateModelNil(), calcMonth, beginDate, endDate, "")
}

func TestDoCalcGroupPowerMonthRankActbufa(t *testing.T) {
	lastDayTime := time.Now().AddDate(0, 0, -1)
	_now := now.New(lastDayTime)
	calcMonth := _now.BeginningOfMonth().Format(utils.MONTH_FORMAT)
	starDate := _now.BeginningOfMonth().Format(utils.COMPACT_MONTH_FORMAT)
	beginDate, endDate := _now.BeginningOfMonth().Format("2006-01-02"), _now.EndOfMonth().Format("2006-01-02")
	_ = group_power_s.BufaDoCalcGroupPowerMonthRankAct(domain.CreateModelNil(), calcMonth, beginDate, endDate, starDate)
chenweijian's avatar
chenweijian committed
53
}
chenweijian's avatar
chenweijian committed
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73

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)
}
hujiebin's avatar
hujiebin committed
74 75 76 77 78 79 80 81 82 83 84

func TestMonthStar(t *testing.T) {
	monthTime, err := time.Parse("200601", "202307")
	if err != nil {
		panic(err)
	}
	redisCli.InitCluster()
	res, err := groupPower_c.GetGroupPowerStarRankPeriod(domain.CreateModelNil(), "month", 242, 1, 0, 10, monthTime.Format("2006-01-02"))
	println(res)
	println(err)
}