Explorar el Código

电脑统计剔除2-8点数据

wangbin hace 3 años
padre
commit
48290eefc1
Se han modificado 2 ficheros con 33 adiciones y 1 borrados
  1. 8 0
      service/log/log_statistics.go
  2. 25 1
      service/log/loging/logical_log.go

+ 8 - 0
service/log/log_statistics.go

@@ -515,7 +515,15 @@ func (s *ServiceStatisticsLog) CreateComputerStatisticsData() {
 	var computer log.Computer
 	computerData, _ := computer.OnlinePcCodeCache()
 	var csReplys []*log.LogComputer
+	// 不统计本地测试电脑
+	notStatistics := map[string]int{
+		"001": 1,
+		"002": 1,
+	}
 	for code, r := range codeMps {
+		if _, ok := notStatistics[code]; ok {
+			continue
+		}
 		accountMps, err := s.LogicalLog.GetComputerPullAccountNumCache(ctx, s.LogicalLog.CurrentDate(), code)
 		if err != nil {
 			continue

+ 25 - 1
service/log/loging/logical_log.go

@@ -668,8 +668,32 @@ func (s *LogicalLog) GetStatisticsComputerRate(ctx context.Context, pcCode strin
 	key := fmt.Sprintf(GameComputerRateCacheKey, s.CurrentDate(), pcCode)
 	key = key + "*"
 	data, _ := s.cache.GetCacheKeys(ctx, key)
+	h := map[string]int{
+		"2": 1,
+		"3": 1,
+		"4": 1,
+		"5": 1,
+		"6": 1,
+		"7": 1,
+		"8": 1,
+	}
+	var i = 0
+	for _, v := range data {
+		key := strings.Split(v, ":")
+		hr := key[len(key)-1:][0]
+		if _, ok := h[hr]; ok {
+			continue
+		}
+		i++
+	}
 	hour := time.Now().Hour()
-	num = hour + 1 - len(data)
+	//num = hour + 1 - len(data)
+	if hour >= 8 {
+		num = hour + 1 - 7 - i
+	} else {
+		notCalculated := hour - 2
+		num = hour + 1 - notCalculated - i
+	}
 	return
 }