mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-07 18:50:26 +08:00
上传流量数据时同时上传服务所属用户ID
This commit is contained in:
@@ -61,20 +61,25 @@ func (this *ServerDailyStatDAO) SaveStats(tx *dbs.Tx, stats []*pb.ServerDailySta
|
||||
var serverUserMap = map[int64]int64{} // serverId => userId
|
||||
var cacheMap = utils.NewCacheMap()
|
||||
for _, stat := range stats {
|
||||
day := timeutil.FormatTime("Ymd", stat.CreatedAt)
|
||||
hour := timeutil.FormatTime("YmdH", stat.CreatedAt)
|
||||
timeFrom := timeutil.FormatTime("His", stat.CreatedAt)
|
||||
timeTo := timeutil.FormatTime("His", stat.CreatedAt+5*60-1) // 5分钟
|
||||
var day = timeutil.FormatTime("Ymd", stat.CreatedAt)
|
||||
var hour = timeutil.FormatTime("YmdH", stat.CreatedAt)
|
||||
var timeFrom = timeutil.FormatTime("His", stat.CreatedAt)
|
||||
var timeTo = timeutil.FormatTime("His", stat.CreatedAt+5*60-1) // 5分钟
|
||||
|
||||
// 所属用户
|
||||
serverUserId, ok := serverUserMap[stat.ServerId]
|
||||
// 用户ID
|
||||
var serverUserId = stat.UserId
|
||||
if serverUserId == 0 {
|
||||
var ok bool
|
||||
serverUserId, ok = serverUserMap[stat.ServerId]
|
||||
if !ok {
|
||||
userId, err := SharedServerDAO.FindServerUserId(tx, stat.ServerId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
serverUserMap[stat.ServerId] = userId
|
||||
serverUserId = userId
|
||||
}
|
||||
}
|
||||
|
||||
_, _, err := this.Query(tx).
|
||||
Param("bytes", stat.Bytes).
|
||||
|
||||
Reference in New Issue
Block a user