small refactor in CreateLongerRecords

This commit is contained in:
Henry Dollman
2024-10-08 12:42:02 -04:00
parent d672017af0
commit 10ef430826

View File

@@ -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())
} }