fix: полный продакшен-фикс dashboard/peer/hysteria по fix35
This commit is contained in:
+4
-9
@@ -8,7 +8,6 @@ import (
|
||||
"gorm.io/gorm/clause"
|
||||
"hy2xs-admin/model/constant"
|
||||
"hy2xs-admin/model/entity"
|
||||
"time"
|
||||
)
|
||||
|
||||
func SaveTrafficSample(sample entity.TrafficSample) error {
|
||||
@@ -29,13 +28,11 @@ func UpsertTrafficAggregateHourly(peerId int64, hourStart int64, rxBytes int64,
|
||||
RxBytes: &rxBytes,
|
||||
TxBytes: &txBytes,
|
||||
}
|
||||
now := time.Now()
|
||||
if tx := sqliteDB.Clauses(clause.OnConflict{
|
||||
Columns: []clause.Column{{Name: "peer_id"}, {Name: "hour_start"}},
|
||||
DoUpdates: clause.Assignments(map[string]interface{}{
|
||||
"rx_bytes": gormExprAdd("rx_bytes", rxBytes),
|
||||
"tx_bytes": gormExprAdd("tx_bytes", txBytes),
|
||||
"update_time": now,
|
||||
"rx_bytes": gormExprAdd("rx_bytes", rxBytes),
|
||||
"tx_bytes": gormExprAdd("tx_bytes", txBytes),
|
||||
}),
|
||||
}).Create(&agg); tx.Error != nil {
|
||||
logrus.Errorf("%v", tx.Error)
|
||||
@@ -54,13 +51,11 @@ func UpsertTrafficAggregateDaily(peerId int64, dayStart int64, rxBytes int64, tx
|
||||
RxBytes: &rxBytes,
|
||||
TxBytes: &txBytes,
|
||||
}
|
||||
now := time.Now()
|
||||
if tx := sqliteDB.Clauses(clause.OnConflict{
|
||||
Columns: []clause.Column{{Name: "peer_id"}, {Name: "day_start"}},
|
||||
DoUpdates: clause.Assignments(map[string]interface{}{
|
||||
"rx_bytes": gormExprAdd("rx_bytes", rxBytes),
|
||||
"tx_bytes": gormExprAdd("tx_bytes", txBytes),
|
||||
"update_time": now,
|
||||
"rx_bytes": gormExprAdd("rx_bytes", rxBytes),
|
||||
"tx_bytes": gormExprAdd("tx_bytes", txBytes),
|
||||
}),
|
||||
}).Create(&agg); tx.Error != nil {
|
||||
logrus.Errorf("%v", tx.Error)
|
||||
|
||||
Reference in New Issue
Block a user