|
@@ -239,7 +239,7 @@ func (l *CronTask) computeStatistic() {
|
|
|
|
|
|
// 获取昨天的第一小时
|
|
|
yesterday := now.AddDate(0, 0, -1)
|
|
|
- yesterdayFirstHour := time.Date(yesterday.Year(), yesterday.Month(), now.Day(), 0, 0, 0, 0, now.Location())
|
|
|
+ yesterdayFirstHour := time.Date(yesterday.Year(), yesterday.Month(), yesterday.Day(), 0, 0, 0, 0, now.Location())
|
|
|
yesterdayInt, _ := strconv.Atoi(yesterdayFirstHour.Format("20060102"))
|
|
|
yesterdayFirstHourInt, _ := strconv.Atoi(yesterdayFirstHour.Format("2006010215"))
|
|
|
|
|
@@ -303,28 +303,7 @@ func (l *CronTask) computeStatistic() {
|
|
|
).Count(l.ctx)
|
|
|
|
|
|
// 如果添加过了就略过
|
|
|
- if dayDataCount > 0 {
|
|
|
- _, err := l.svcCtx.DB.UsageStatisticDay.Update().
|
|
|
- Where(
|
|
|
- usagestatisticday.Type(1),
|
|
|
- usagestatisticday.BotID(wxinfo.Wxid),
|
|
|
- usagestatisticday.Addtime(uint64(yesterdayInt)),
|
|
|
- ).
|
|
|
- SetAiResponse(aiResponse).
|
|
|
- SetSopRun(sopRun).
|
|
|
- SetTotalFriend(totalFriend).
|
|
|
- SetTotalGroup(totalGroup).
|
|
|
- SetAccountBalance(accountBalance).
|
|
|
- SetConsumeToken(consumeToken).
|
|
|
- SetActiveUser(activeUser).
|
|
|
- SetNewUser(newUser).
|
|
|
- SetLabelDist(lc).
|
|
|
- Save(l.ctx)
|
|
|
- if err != nil {
|
|
|
- l.Errorf("create day data error:%v \n", err)
|
|
|
- continue
|
|
|
- }
|
|
|
- } else {
|
|
|
+ if dayDataCount == 0 && yesterdayLastHourInt <= currentHourInt {
|
|
|
_, err := l.svcCtx.DB.UsageStatisticDay.Create().
|
|
|
SetAddtime(uint64(yesterdayInt)).
|
|
|
SetType(1).
|
|
@@ -355,29 +334,7 @@ func (l *CronTask) computeStatistic() {
|
|
|
).Count(l.ctx)
|
|
|
|
|
|
// 如果添加过了就略过
|
|
|
- if dayDataCount > 0 {
|
|
|
- _, err := l.svcCtx.DB.UsageStatisticDay.Update().
|
|
|
- Where(
|
|
|
- usagestatisticday.Type(1),
|
|
|
- usagestatisticday.OrganizationID(orgID),
|
|
|
- usagestatisticday.BotID(""),
|
|
|
- usagestatisticday.Addtime(uint64(yesterdayInt)),
|
|
|
- ).
|
|
|
- SetAiResponse(orgAiResponseInt).
|
|
|
- SetSopRun(orgSopRunInt).
|
|
|
- SetTotalFriend(orgFriendCountInt).
|
|
|
- SetTotalGroup(orgGroupCountInt).
|
|
|
- SetAccountBalance(orgAccountBalanceInt).
|
|
|
- SetConsumeToken(orgConsumeTokenInt).
|
|
|
- SetActiveUser(orgActiveUserInt).
|
|
|
- SetNewUser(orgNewUserInt).
|
|
|
- SetNotNilLabelDist(LabelsCountSet[orgID]).
|
|
|
- Save(l.ctx)
|
|
|
- if err != nil {
|
|
|
- l.Errorf("create day data error:%v \n", err)
|
|
|
- continue
|
|
|
- }
|
|
|
- } else {
|
|
|
+ if dayDataCount == 0 && yesterdayLastHourInt <= currentHourInt {
|
|
|
_, err := l.svcCtx.DB.UsageStatisticDay.Create().
|
|
|
SetAddtime(uint64(yesterdayInt)).
|
|
|
SetType(1).
|
|
@@ -408,28 +365,7 @@ func (l *CronTask) computeStatistic() {
|
|
|
).Count(l.ctx)
|
|
|
|
|
|
// 如果添加过了就略过
|
|
|
- if dayDataCount > 0 {
|
|
|
- _, err = l.svcCtx.DB.UsageStatisticDay.Update().
|
|
|
- Where(
|
|
|
- usagestatisticday.Type(1),
|
|
|
- usagestatisticday.OrganizationID(0),
|
|
|
- usagestatisticday.BotID(""),
|
|
|
- usagestatisticday.Addtime(uint64(yesterdayInt)),
|
|
|
- ).
|
|
|
- SetAiResponse(allDayAiResponseInt).
|
|
|
- SetSopRun(allDaySopRunInt).
|
|
|
- SetTotalFriend(allDayFriendCountInt).
|
|
|
- SetTotalGroup(allDayGroupCountInt).
|
|
|
- SetAccountBalance(allDayAccountBalanceInt).
|
|
|
- SetConsumeToken(allDayConsumeTokenInt).
|
|
|
- SetActiveUser(allDayActiveUserInt).
|
|
|
- SetNewUser(allDayNewUserInt).
|
|
|
- SetLabelDist(lc).
|
|
|
- Save(l.ctx)
|
|
|
- if err != nil {
|
|
|
- l.Errorf("create day data error:%v \n", err)
|
|
|
- }
|
|
|
- } else {
|
|
|
+ if dayDataCount == 0 && yesterdayLastHourInt <= currentHourInt {
|
|
|
_, err = l.svcCtx.DB.UsageStatisticDay.Create().
|
|
|
SetAddtime(uint64(day)).
|
|
|
SetType(1).
|