|
@@ -101,6 +101,7 @@ func (l *GetChartsLogic) GetCharts(req *types.ChartsReq) (resp *types.ChartsResp
|
|
|
totalFriend := types.ChartsUint{}
|
|
|
totalGroup := types.ChartsUint{}
|
|
|
accountBalance := types.ChartsUint{}
|
|
|
+ accountBalance.LabelText = "积分"
|
|
|
consumeToken := types.ChartsUint{}
|
|
|
activeUser := types.ChartsUint{}
|
|
|
newUser := types.ChartsInt{}
|
|
@@ -123,7 +124,11 @@ func (l *GetChartsLogic) GetCharts(req *types.ChartsReq) (resp *types.ChartsResp
|
|
|
|
|
|
var predicates []predicate.UsageStatisticHour
|
|
|
predicates = append(predicates, usagestatistichour.OrganizationID(organizationId))
|
|
|
- predicates = append(predicates, usagestatistichour.BotID(""))
|
|
|
+ if req.Wxid != nil {
|
|
|
+ predicates = append(predicates, usagestatistichour.BotID(*req.Wxid))
|
|
|
+ } else {
|
|
|
+ predicates = append(predicates, usagestatistichour.BotID(""))
|
|
|
+ }
|
|
|
predicates = append(predicates, usagestatistichour.AddtimeGTE(startAddTime))
|
|
|
predicates = append(predicates, usagestatistichour.AddtimeLTE(nextDayAddTime))
|
|
|
usageStatisticHour, err := l.svcCtx.DB.UsageStatisticHour.Query().Where(predicates...).All(l.ctx)
|
|
@@ -135,30 +140,37 @@ func (l *GetChartsLogic) GetCharts(req *types.ChartsReq) (resp *types.ChartsResp
|
|
|
aiResponse.Count += hourData.AiResponse
|
|
|
aiResponse.Val = append(aiResponse.Val, hourData.AiResponse)
|
|
|
aiResponse.Label = append(aiResponse.Label, fmt.Sprintf("%02d点", addtimeLastTwoDigits))
|
|
|
+ aiResponse.LabelText = "次"
|
|
|
|
|
|
sopRun.Count += hourData.SopRun
|
|
|
sopRun.Val = append(sopRun.Val, hourData.SopRun)
|
|
|
sopRun.Label = append(sopRun.Label, fmt.Sprintf("%02d点", addtimeLastTwoDigits))
|
|
|
+ sopRun.LabelText = "次"
|
|
|
|
|
|
totalFriend.Count = hourData.TotalFriend
|
|
|
totalFriend.Val = append(totalFriend.Val, hourData.TotalFriend)
|
|
|
totalFriend.Label = append(totalFriend.Label, fmt.Sprintf("%02d点", addtimeLastTwoDigits))
|
|
|
+ totalFriend.LabelText = "个"
|
|
|
|
|
|
totalGroup.Count = hourData.TotalGroup
|
|
|
totalGroup.Val = append(totalGroup.Val, hourData.TotalGroup)
|
|
|
totalGroup.Label = append(totalGroup.Label, fmt.Sprintf("%02d点", addtimeLastTwoDigits))
|
|
|
+ totalGroup.LabelText = "个"
|
|
|
|
|
|
consumeToken.Count += hourData.ConsumeToken
|
|
|
consumeToken.Val = append(consumeToken.Val, hourData.ConsumeToken)
|
|
|
consumeToken.Label = append(consumeToken.Label, fmt.Sprintf("%02d点", addtimeLastTwoDigits))
|
|
|
+ consumeToken.LabelText = "token"
|
|
|
|
|
|
activeUser.Count = hourData.ActiveUser
|
|
|
activeUser.Val = append(activeUser.Val, hourData.ActiveUser)
|
|
|
activeUser.Label = append(activeUser.Label, fmt.Sprintf("%02d点", addtimeLastTwoDigits))
|
|
|
+ activeUser.LabelText = "个"
|
|
|
|
|
|
newUser.Count += hourData.NewUser
|
|
|
newUser.Val = append(newUser.Val, hourData.NewUser)
|
|
|
newUser.Label = append(newUser.Label, fmt.Sprintf("%02d点", addtimeLastTwoDigits))
|
|
|
+ newUser.LabelText = "个"
|
|
|
}
|
|
|
hourLen := len(usageStatisticHour)
|
|
|
if hourLen > 0 {
|
|
@@ -193,7 +205,11 @@ func (l *GetChartsLogic) GetCharts(req *types.ChartsReq) (resp *types.ChartsResp
|
|
|
|
|
|
var predicatesDay []predicate.UsageStatisticDay
|
|
|
predicatesDay = append(predicatesDay, usagestatisticday.OrganizationID(organizationId))
|
|
|
- predicatesDay = append(predicatesDay, usagestatisticday.BotID(""))
|
|
|
+ if req.Wxid != nil {
|
|
|
+ predicatesDay = append(predicatesDay, usagestatisticday.BotID(*req.Wxid))
|
|
|
+ } else {
|
|
|
+ predicatesDay = append(predicatesDay, usagestatisticday.BotID(""))
|
|
|
+ }
|
|
|
predicatesDay = append(predicatesDay, usagestatisticday.AddtimeGTE(startAddTime))
|
|
|
predicatesDay = append(predicatesDay, usagestatisticday.AddtimeLTE(endAddTime))
|
|
|
usageStatisticDay, err := l.svcCtx.DB.UsageStatisticDay.Query().Where(predicatesDay...).All(l.ctx)
|
|
@@ -204,30 +220,37 @@ func (l *GetChartsLogic) GetCharts(req *types.ChartsReq) (resp *types.ChartsResp
|
|
|
aiResponse.Count = aiResponse.Count + dayData.AiResponse
|
|
|
aiResponse.Val = append(aiResponse.Val, dayData.AiResponse)
|
|
|
aiResponse.Label = append(aiResponse.Label, fmt.Sprintf("%d", dayData.Addtime))
|
|
|
+ aiResponse.LabelText = "次"
|
|
|
|
|
|
sopRun.Count += dayData.SopRun
|
|
|
sopRun.Val = append(sopRun.Val, dayData.SopRun)
|
|
|
sopRun.Label = append(sopRun.Label, fmt.Sprintf("%d", dayData.Addtime))
|
|
|
+ sopRun.LabelText = "次"
|
|
|
|
|
|
totalFriend.Count = dayData.TotalFriend
|
|
|
totalFriend.Val = append(totalFriend.Val, dayData.TotalFriend)
|
|
|
totalFriend.Label = append(totalFriend.Label, fmt.Sprintf("%d", dayData.Addtime))
|
|
|
+ totalFriend.LabelText = "个"
|
|
|
|
|
|
totalGroup.Count = dayData.TotalGroup
|
|
|
totalGroup.Val = append(totalGroup.Val, dayData.TotalGroup)
|
|
|
totalGroup.Label = append(totalGroup.Label, fmt.Sprintf("%d", dayData.Addtime))
|
|
|
+ totalGroup.LabelText = "个"
|
|
|
|
|
|
consumeToken.Count += dayData.ConsumeToken
|
|
|
consumeToken.Val = append(consumeToken.Val, dayData.ConsumeToken)
|
|
|
consumeToken.Label = append(consumeToken.Label, fmt.Sprintf("%d", dayData.Addtime))
|
|
|
+ consumeToken.LabelText = "token"
|
|
|
|
|
|
activeUser.Count = dayData.ActiveUser
|
|
|
activeUser.Val = append(activeUser.Val, dayData.ActiveUser)
|
|
|
activeUser.Label = append(activeUser.Label, fmt.Sprintf("%d", dayData.Addtime))
|
|
|
+ activeUser.LabelText = "个"
|
|
|
|
|
|
newUser.Count += dayData.NewUser
|
|
|
newUser.Val = append(newUser.Val, dayData.NewUser)
|
|
|
newUser.Label = append(newUser.Label, fmt.Sprintf("%d", dayData.Addtime))
|
|
|
+ newUser.LabelText = "个"
|
|
|
}
|
|
|
dayLen := len(usageStatisticDay)
|
|
|
if dayLen > 0 {
|
|
@@ -258,7 +281,11 @@ func (l *GetChartsLogic) GetCharts(req *types.ChartsReq) (resp *types.ChartsResp
|
|
|
|
|
|
var predicates []predicate.UsageStatisticHour
|
|
|
predicates = append(predicates, usagestatistichour.OrganizationID(organizationId))
|
|
|
- predicates = append(predicates, usagestatistichour.BotID(""))
|
|
|
+ if req.Wxid != nil {
|
|
|
+ predicates = append(predicates, usagestatistichour.BotID(*req.Wxid))
|
|
|
+ } else {
|
|
|
+ predicates = append(predicates, usagestatistichour.BotID(""))
|
|
|
+ }
|
|
|
predicates = append(predicates, usagestatistichour.AddtimeGTE(startOfDayAddTime))
|
|
|
usageStatisticHour, err := l.svcCtx.DB.UsageStatisticHour.Query().Where(predicates...).All(l.ctx)
|
|
|
if err != nil {
|
|
@@ -287,10 +314,12 @@ func (l *GetChartsLogic) GetCharts(req *types.ChartsReq) (resp *types.ChartsResp
|
|
|
aiResponse.Count = aiResponse.Count + aiResponseOfDay
|
|
|
aiResponse.Val = append(aiResponse.Val, aiResponseOfDay)
|
|
|
aiResponse.Label = append(aiResponse.Label, "今日")
|
|
|
+ aiResponse.LabelText = "次"
|
|
|
|
|
|
sopRun.Count = sopRun.Count + sopRunOfDay
|
|
|
sopRun.Val = append(sopRun.Val, sopRunOfDay)
|
|
|
sopRun.Label = append(sopRun.Label, "今日")
|
|
|
+ sopRun.LabelText = "次"
|
|
|
|
|
|
totalFriend.Count = totalFriendOfDay
|
|
|
totalFriend.Val = append(totalFriend.Val, totalFriendOfDay)
|
|
@@ -299,6 +328,7 @@ func (l *GetChartsLogic) GetCharts(req *types.ChartsReq) (resp *types.ChartsResp
|
|
|
if tfLen > 0 && totalFriend.Val[0] > 0 {
|
|
|
totalFriend.Rate = float32((totalFriend.Val[tfLen-1] - totalFriend.Val[0]) / totalFriend.Val[0])
|
|
|
}
|
|
|
+ totalFriend.LabelText = "个"
|
|
|
|
|
|
totalGroup.Count = totalGroupOfDay
|
|
|
totalGroup.Val = append(totalGroup.Val, totalGroupOfDay)
|
|
@@ -307,10 +337,12 @@ func (l *GetChartsLogic) GetCharts(req *types.ChartsReq) (resp *types.ChartsResp
|
|
|
if tgLen > 0 && totalGroup.Val[0] > 0 {
|
|
|
totalGroup.Rate = float32((totalGroup.Val[tgLen-1] - totalGroup.Val[0]) / totalGroup.Val[0])
|
|
|
}
|
|
|
+ totalGroup.LabelText = "个"
|
|
|
|
|
|
consumeToken.Count = consumeToken.Count + consumeTokenOfDay
|
|
|
consumeToken.Val = append(consumeToken.Val, consumeTokenOfDay)
|
|
|
consumeToken.Label = append(consumeToken.Label, "今日")
|
|
|
+ consumeToken.LabelText = "token"
|
|
|
|
|
|
activeUser.Count = activeUserOfDay
|
|
|
activeUser.Val = append(activeUser.Val, activeUserOfDay)
|
|
@@ -319,6 +351,7 @@ func (l *GetChartsLogic) GetCharts(req *types.ChartsReq) (resp *types.ChartsResp
|
|
|
if auLen > 0 && activeUser.Val[0] > 0 {
|
|
|
activeUser.Rate = float32((activeUser.Val[auLen-1] - activeUser.Val[0]) / activeUser.Val[0])
|
|
|
}
|
|
|
+ activeUser.LabelText = "个"
|
|
|
|
|
|
newUser.Count = newUserOfDay
|
|
|
newUser.Val = append(newUser.Val, newUserOfDay)
|
|
@@ -327,6 +360,7 @@ func (l *GetChartsLogic) GetCharts(req *types.ChartsReq) (resp *types.ChartsResp
|
|
|
if nuLen > 0 && newUser.Val[0] > 0 {
|
|
|
newUser.Rate = float32((newUser.Val[nuLen-1] - newUser.Val[0]) / newUser.Val[0])
|
|
|
}
|
|
|
+ newUser.LabelText = "个"
|
|
|
|
|
|
labelDists = usageStatisticHour[hourLen-1].LabelDist
|
|
|
}
|