mirror of
https://github.com/fankes/beszel.git
synced 2025-10-20 02:09:28 +08:00
small refactor in CreateLongerRecords
This commit is contained in:
@@ -118,17 +118,15 @@ func (rm *RecordManager) CreateLongerRecords() {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// average the shorter records and create longer record
|
// average the shorter records and create longer record
|
||||||
var stats interface{}
|
|
||||||
switch collection.Name {
|
|
||||||
case "system_stats":
|
|
||||||
stats = rm.AverageSystemStats(allShorterRecords)
|
|
||||||
case "container_stats":
|
|
||||||
stats = rm.AverageContainerStats(allShorterRecords)
|
|
||||||
}
|
|
||||||
longerRecord := models.NewRecord(collection)
|
longerRecord := models.NewRecord(collection)
|
||||||
longerRecord.Set("system", system.Id)
|
longerRecord.Set("system", system.Id)
|
||||||
longerRecord.Set("stats", stats)
|
|
||||||
longerRecord.Set("type", recordData.longerType)
|
longerRecord.Set("type", recordData.longerType)
|
||||||
|
switch collection.Name {
|
||||||
|
case "system_stats":
|
||||||
|
longerRecord.Set("stats", rm.AverageSystemStats(allShorterRecords))
|
||||||
|
case "container_stats":
|
||||||
|
longerRecord.Set("stats", rm.AverageContainerStats(allShorterRecords))
|
||||||
|
}
|
||||||
if err := txDao.SaveRecord(longerRecord); err != nil {
|
if err := txDao.SaveRecord(longerRecord); err != nil {
|
||||||
log.Println("failed to save longer record", "err", err.Error())
|
log.Println("failed to save longer record", "err", err.Error())
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user