上传统计数据时自动清理旧数据

This commit is contained in:
刘祥超
2021-07-28 17:04:31 +08:00
parent a15ad7dd04
commit 3b2f6060b8
5 changed files with 34 additions and 4 deletions

View File

@@ -27,6 +27,12 @@ func (this *MetricStatService) UploadMetricStats(ctx context.Context, req *pb.Up
return nil, err
}
// 删除旧的数据
err = models.SharedMetricStatDAO.DeleteNodeItemStats(tx, nodeId, req.ServerId, req.ItemId, req.Time)
if err != nil {
return nil, err
}
for _, stat := range req.MetricStats {
err := models.SharedMetricStatDAO.CreateStat(tx, stat.Hash, clusterId, nodeId, req.ServerId, req.ItemId, stat.Keys, float64(stat.Value), req.Time, req.Version)
if err != nil {