|
@@ -64,7 +64,7 @@ func (l *GetChartsLogic) GetCharts(req *types.ChartsReq) (resp *types.ChartsResp
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
- l.Infof("----------------layoutsType--------------: %d", layoutsType)
|
|
|
+
|
|
|
if err != nil {
|
|
|
fmt.Println("解析开始时间失败:", err)
|
|
|
return
|
|
@@ -93,14 +93,38 @@ func (l *GetChartsLogic) GetCharts(req *types.ChartsReq) (resp *types.ChartsResp
|
|
|
}
|
|
|
|
|
|
// 定义变量
|
|
|
- var aiResponse types.ChartsUint
|
|
|
- var sopRun types.ChartsUint
|
|
|
- var totalFriend types.ChartsUint
|
|
|
- var totalGroup types.ChartsUint
|
|
|
- var accountBalance types.ChartsUint
|
|
|
- var consumeToken types.ChartsUint
|
|
|
- var activeUser types.ChartsUint
|
|
|
- var newUser types.ChartsInt
|
|
|
+ aiResponse := types.ChartsUint{
|
|
|
+ Count: 0,
|
|
|
+ Val: []uint64{}, // 初始化切片
|
|
|
+ }
|
|
|
+ sopRun := types.ChartsUint{
|
|
|
+ Count: 0,
|
|
|
+ Val: []uint64{}, // 初始化切片
|
|
|
+ }
|
|
|
+ totalFriend := types.ChartsUint{
|
|
|
+ Count: 0,
|
|
|
+ Val: []uint64{}, // 初始化切片
|
|
|
+ }
|
|
|
+ totalGroup := types.ChartsUint{
|
|
|
+ Count: 0,
|
|
|
+ Val: []uint64{}, // 初始化切片
|
|
|
+ }
|
|
|
+ accountBalance := types.ChartsUint{
|
|
|
+ Count: 0,
|
|
|
+ Val: []uint64{}, // 初始化切片
|
|
|
+ }
|
|
|
+ consumeToken := types.ChartsUint{
|
|
|
+ Count: 0,
|
|
|
+ Val: []uint64{}, // 初始化切片
|
|
|
+ }
|
|
|
+ activeUser := types.ChartsUint{
|
|
|
+ Count: 0,
|
|
|
+ Val: []uint64{}, // 初始化切片
|
|
|
+ }
|
|
|
+ newUser := types.ChartsInt{
|
|
|
+ Count: 0,
|
|
|
+ Val: []int64{}, // 初始化切片
|
|
|
+ }
|
|
|
|
|
|
var aiResponseSum []SumUint
|
|
|
var sopRunSum []SumUint
|
|
@@ -131,32 +155,24 @@ func (l *GetChartsLogic) GetCharts(req *types.ChartsReq) (resp *types.ChartsResp
|
|
|
_ = usageStatisticHour.Aggregate(ent.As(ent.Sum(usagestatistichour.FieldActiveUser), "value")).Scan(l.ctx, &activeUserSum)
|
|
|
_ = usageStatisticHour.Aggregate(ent.As(ent.Sum(usagestatistichour.FieldNewUser), "value")).Scan(l.ctx, &newUserSum)
|
|
|
for _, ar := range aiResponseSum {
|
|
|
- aiResponse = types.ChartsUint{
|
|
|
- Count: aiResponse.Count + ar.Value,
|
|
|
- Val: append(aiResponse.Val, ar.Value),
|
|
|
- }
|
|
|
+ aiResponse.Count = aiResponse.Count + ar.Value
|
|
|
+ aiResponse.Val = append(aiResponse.Val, ar.Value)
|
|
|
}
|
|
|
for _, sr := range sopRunSum {
|
|
|
- sopRun = types.ChartsUint{
|
|
|
- Count: sopRun.Count + sr.Value,
|
|
|
- Val: append(sopRun.Val, sr.Value),
|
|
|
- }
|
|
|
+ sopRun.Count = sopRun.Count + sr.Value
|
|
|
+ sopRun.Val = append(sopRun.Val, sr.Value)
|
|
|
}
|
|
|
for _, tf := range totalFriendSum {
|
|
|
- totalFriend = types.ChartsUint{
|
|
|
- Count: tf.Value,
|
|
|
- Val: append(totalFriend.Val, tf.Value),
|
|
|
- }
|
|
|
+ totalFriend.Count = tf.Value
|
|
|
+ totalFriend.Val = append(totalFriend.Val, tf.Value)
|
|
|
}
|
|
|
totalFriendLen := len(totalFriendSum)
|
|
|
if totalFriendLen > 0 && totalFriendSum[0].Value > 0 {
|
|
|
totalFriend.Rate = float32((totalFriendSum[totalFriendLen-1].Value - totalFriendSum[0].Value) / totalFriendSum[0].Value)
|
|
|
}
|
|
|
for _, tg := range totalGroupSum {
|
|
|
- totalGroup = types.ChartsUint{
|
|
|
- Count: tg.Value,
|
|
|
- Val: append(totalGroup.Val, tg.Value),
|
|
|
- }
|
|
|
+ totalGroup.Count = tg.Value
|
|
|
+ totalGroup.Val = append(totalGroup.Val, tg.Value)
|
|
|
}
|
|
|
totalGroupLen := len(totalGroupSum)
|
|
|
if totalGroupLen > 0 && totalGroupSum[0].Value > 0 {
|
|
@@ -164,17 +180,13 @@ func (l *GetChartsLogic) GetCharts(req *types.ChartsReq) (resp *types.ChartsResp
|
|
|
}
|
|
|
for _, ct := range consumeTokenSum {
|
|
|
addtimeLastTwoDigits := ct.Addtime % 100
|
|
|
- consumeToken = types.ChartsUint{
|
|
|
- Count: consumeToken.Count + ct.Value,
|
|
|
- Val: append(consumeToken.Val, ct.Value),
|
|
|
- Label: append(consumeToken.Label, fmt.Sprintf("%02d", addtimeLastTwoDigits)),
|
|
|
- }
|
|
|
+ consumeToken.Count = consumeToken.Count + ct.Value
|
|
|
+ consumeToken.Val = append(consumeToken.Val, ct.Value)
|
|
|
+ consumeToken.Label = append(consumeToken.Label, fmt.Sprintf("%02d", addtimeLastTwoDigits))
|
|
|
}
|
|
|
for _, au := range activeUserSum {
|
|
|
- activeUser = types.ChartsUint{
|
|
|
- Count: au.Value,
|
|
|
- Val: append(activeUser.Val, au.Value),
|
|
|
- }
|
|
|
+ activeUser.Count = au.Value
|
|
|
+ activeUser.Val = append(activeUser.Val, au.Value)
|
|
|
}
|
|
|
activeUserLen := len(activeUserSum)
|
|
|
if activeUserLen > 0 && activeUserSum[0].Value > 0 {
|
|
@@ -182,11 +194,9 @@ func (l *GetChartsLogic) GetCharts(req *types.ChartsReq) (resp *types.ChartsResp
|
|
|
}
|
|
|
for _, nu := range newUserSum {
|
|
|
addtimeLastTwoDigits := nu.Addtime % 100
|
|
|
- newUser = types.ChartsInt{
|
|
|
- Count: nu.Value,
|
|
|
- Val: append(newUser.Val, nu.Value),
|
|
|
- Label: append(newUser.Label, fmt.Sprintf("%02d", addtimeLastTwoDigits)),
|
|
|
- }
|
|
|
+ newUser.Count = nu.Value
|
|
|
+ newUser.Val = append(newUser.Val, nu.Value)
|
|
|
+ newUser.Label = append(newUser.Label, fmt.Sprintf("%02d", addtimeLastTwoDigits))
|
|
|
}
|
|
|
newUserLen := len(newUserSum)
|
|
|
if newUserLen > 0 && newUserSum[0].Value > 0 {
|
|
@@ -213,6 +223,11 @@ func (l *GetChartsLogic) GetCharts(req *types.ChartsReq) (resp *types.ChartsResp
|
|
|
usagestatisticday.AddtimeLTE(endAddTime),
|
|
|
).
|
|
|
GroupBy(usagestatisticday.FieldAddtime)
|
|
|
+ //count, _ := usageStatisticDay..Count(l.ctx)
|
|
|
+ //l.Infof("----------------count--------------: %d", count)
|
|
|
+ var v []SumUint
|
|
|
+ _ = usageStatisticDay.Aggregate(ent.As(ent.Count(), "value")).Scan(l.ctx, &v)
|
|
|
+ l.Infof("----------------count--------------: %d", v)
|
|
|
_ = usageStatisticDay.Aggregate(ent.As(ent.Sum(usagestatisticday.FieldAiResponse), "value")).Scan(l.ctx, &aiResponseSum)
|
|
|
_ = usageStatisticDay.Aggregate(ent.As(ent.Sum(usagestatisticday.FieldSopRun), "value")).Scan(l.ctx, &sopRunSum)
|
|
|
_ = usageStatisticDay.Aggregate(ent.As(ent.Sum(usagestatisticday.FieldTotalFriend), "value")).Scan(l.ctx, &totalFriendSum)
|
|
@@ -222,23 +237,17 @@ func (l *GetChartsLogic) GetCharts(req *types.ChartsReq) (resp *types.ChartsResp
|
|
|
_ = usageStatisticDay.Aggregate(ent.As(ent.Sum(usagestatisticday.FieldNewUser), "value")).Scan(l.ctx, &newUserSum)
|
|
|
|
|
|
for _, ar := range aiResponseSum {
|
|
|
- aiResponse = types.ChartsUint{
|
|
|
- Count: aiResponse.Count + ar.Value,
|
|
|
- Val: append(aiResponse.Val, ar.Value),
|
|
|
- }
|
|
|
+ aiResponse.Count = aiResponse.Count + ar.Value
|
|
|
+ aiResponse.Val = append(aiResponse.Val, ar.Value)
|
|
|
}
|
|
|
for _, sr := range sopRunSum {
|
|
|
- sopRun = types.ChartsUint{
|
|
|
- Count: sopRun.Count + sr.Value,
|
|
|
- Val: append(sopRun.Val, sr.Value),
|
|
|
- }
|
|
|
+ sopRun.Count = sopRun.Count + sr.Value
|
|
|
+ sopRun.Val = append(sopRun.Val, sr.Value)
|
|
|
}
|
|
|
|
|
|
for _, tf := range totalFriendSum {
|
|
|
- totalFriend = types.ChartsUint{
|
|
|
- Count: tf.Value,
|
|
|
- Val: append(totalFriend.Val, tf.Value),
|
|
|
- }
|
|
|
+ totalFriend.Count = tf.Value
|
|
|
+ totalFriend.Val = append(totalFriend.Val, tf.Value)
|
|
|
}
|
|
|
totalFriendLen := len(totalFriendSum)
|
|
|
if totalFriendLen > 0 && totalFriendSum[0].Value > 0 {
|
|
@@ -246,10 +255,8 @@ func (l *GetChartsLogic) GetCharts(req *types.ChartsReq) (resp *types.ChartsResp
|
|
|
}
|
|
|
|
|
|
for _, tg := range totalGroupSum {
|
|
|
- totalGroup = types.ChartsUint{
|
|
|
- Count: tg.Value,
|
|
|
- Val: append(totalGroup.Val, tg.Value),
|
|
|
- }
|
|
|
+ totalGroup.Count = tg.Value
|
|
|
+ totalGroup.Val = append(totalGroup.Val, tg.Value)
|
|
|
}
|
|
|
totalGroupLen := len(totalGroupSum)
|
|
|
if totalGroupLen > 0 && totalGroupSum[0].Value > 0 {
|
|
@@ -257,18 +264,14 @@ func (l *GetChartsLogic) GetCharts(req *types.ChartsReq) (resp *types.ChartsResp
|
|
|
}
|
|
|
|
|
|
for _, ct := range consumeTokenSum {
|
|
|
- addtimeLastTwoDigits := ct.Addtime % 100
|
|
|
- consumeToken = types.ChartsUint{
|
|
|
- Count: consumeToken.Count + ct.Value,
|
|
|
- Val: append(consumeToken.Val, ct.Value),
|
|
|
- Label: append(consumeToken.Label, fmt.Sprintf("%02d", addtimeLastTwoDigits)),
|
|
|
- }
|
|
|
+ //addtimeLastTwoDigits := ct.Addtime % 100
|
|
|
+ consumeToken.Count = consumeToken.Count + ct.Value
|
|
|
+ consumeToken.Val = append(consumeToken.Val, ct.Value)
|
|
|
+ consumeToken.Label = append(consumeToken.Label, fmt.Sprintf("%d", ct.Addtime))
|
|
|
}
|
|
|
for _, au := range activeUserSum {
|
|
|
- activeUser = types.ChartsUint{
|
|
|
- Count: au.Value,
|
|
|
- Val: append(activeUser.Val, au.Value),
|
|
|
- }
|
|
|
+ activeUser.Count = au.Value
|
|
|
+ activeUser.Val = append(activeUser.Val, au.Value)
|
|
|
}
|
|
|
activeUserLen := len(activeUserSum)
|
|
|
if activeUserLen > 0 && activeUserSum[0].Value > 0 {
|
|
@@ -276,11 +279,9 @@ func (l *GetChartsLogic) GetCharts(req *types.ChartsReq) (resp *types.ChartsResp
|
|
|
}
|
|
|
for _, nu := range newUserSum {
|
|
|
addtimeLastTwoDigits := nu.Addtime % 100
|
|
|
- newUser = types.ChartsInt{
|
|
|
- Count: nu.Value,
|
|
|
- Val: append(newUser.Val, nu.Value),
|
|
|
- Label: append(newUser.Label, fmt.Sprintf("%02d", addtimeLastTwoDigits)),
|
|
|
- }
|
|
|
+ newUser.Count = nu.Value
|
|
|
+ newUser.Val = append(newUser.Val, nu.Value)
|
|
|
+ newUser.Label = append(newUser.Label, fmt.Sprintf("%02d", addtimeLastTwoDigits))
|
|
|
}
|
|
|
newUserLen := len(newUserSum)
|
|
|
if newUserLen > 0 && newUserSum[0].Value > 0 {
|
|
@@ -323,48 +324,40 @@ func (l *GetChartsLogic) GetCharts(req *types.ChartsReq) (resp *types.ChartsResp
|
|
|
activeUserOfDay = usageStatisticHour[hourLen-1].ActiveUser
|
|
|
newUserOfDay = usageStatisticHour[hourLen-1].NewUser
|
|
|
|
|
|
- aiResponse = types.ChartsUint{
|
|
|
- Count: aiResponse.Count + aiResponseOfDay,
|
|
|
- Val: append(aiResponse.Val, aiResponseOfDay),
|
|
|
- }
|
|
|
- sopRun = types.ChartsUint{
|
|
|
- Count: sopRun.Count + sopRunOfDay,
|
|
|
- Val: append(sopRun.Val, sopRunOfDay),
|
|
|
- }
|
|
|
- totalFriend = types.ChartsUint{
|
|
|
- Count: totalFriendOfDay,
|
|
|
- Val: append(totalFriend.Val, totalFriendOfDay),
|
|
|
- }
|
|
|
+ aiResponse.Count = aiResponse.Count + aiResponseOfDay
|
|
|
+ aiResponse.Val = append(aiResponse.Val, aiResponseOfDay)
|
|
|
+
|
|
|
+ sopRun.Count = sopRun.Count + sopRunOfDay
|
|
|
+ sopRun.Val = append(sopRun.Val, sopRunOfDay)
|
|
|
+
|
|
|
+ totalFriend.Count = totalFriendOfDay
|
|
|
+ totalFriend.Val = append(totalFriend.Val, totalFriendOfDay)
|
|
|
tfLen := len(totalFriend.Val)
|
|
|
if tfLen > 0 && totalFriend.Val[0] > 0 {
|
|
|
totalFriend.Rate = float32((totalFriend.Val[tfLen-1] - totalFriend.Val[0]) / totalFriend.Val[0])
|
|
|
}
|
|
|
- totalGroup = types.ChartsUint{
|
|
|
- Count: totalGroupOfDay,
|
|
|
- Val: append(totalGroup.Val, totalGroupOfDay),
|
|
|
- }
|
|
|
+
|
|
|
+ totalGroup.Count = totalGroupOfDay
|
|
|
+ totalGroup.Val = append(totalGroup.Val, totalGroupOfDay)
|
|
|
tgLen := len(totalGroup.Val)
|
|
|
if tgLen > 0 && totalGroup.Val[0] > 0 {
|
|
|
totalGroup.Rate = float32((totalGroup.Val[tgLen-1] - totalGroup.Val[0]) / totalGroup.Val[0])
|
|
|
}
|
|
|
- consumeToken = types.ChartsUint{
|
|
|
- Count: consumeToken.Count + consumeTokenOfDay,
|
|
|
- Val: append(consumeToken.Val, consumeTokenOfDay),
|
|
|
- Label: append(consumeToken.Label, "今日"),
|
|
|
- }
|
|
|
- activeUser = types.ChartsUint{
|
|
|
- Count: activeUserOfDay,
|
|
|
- Val: append(activeUser.Val, activeUserOfDay),
|
|
|
- }
|
|
|
+
|
|
|
+ consumeToken.Count = consumeToken.Count + consumeTokenOfDay
|
|
|
+ consumeToken.Val = append(consumeToken.Val, consumeTokenOfDay)
|
|
|
+ consumeToken.Label = append(consumeToken.Label, "今日")
|
|
|
+
|
|
|
+ activeUser.Count = activeUserOfDay
|
|
|
+ activeUser.Val = append(activeUser.Val, activeUserOfDay)
|
|
|
auLen := len(activeUser.Val)
|
|
|
if auLen > 0 && activeUser.Val[0] > 0 {
|
|
|
activeUser.Rate = float32((activeUser.Val[auLen-1] - activeUser.Val[0]) / activeUser.Val[0])
|
|
|
}
|
|
|
- newUser = types.ChartsInt{
|
|
|
- Count: newUserOfDay,
|
|
|
- Val: append(newUser.Val, newUserOfDay),
|
|
|
- Label: append(newUser.Label, "今日"),
|
|
|
- }
|
|
|
+
|
|
|
+ newUser.Count = newUserOfDay
|
|
|
+ newUser.Val = append(newUser.Val, newUserOfDay)
|
|
|
+ newUser.Label = append(newUser.Label, "今日")
|
|
|
nuLen := len(newUser.Val)
|
|
|
if nuLen > 0 && newUser.Val[0] > 0 {
|
|
|
newUser.Rate = float32((newUser.Val[nuLen-1] - newUser.Val[0]) / newUser.Val[0])
|