From bd19230cbffb7085dfe0db839aaf17fd1193bc38 Mon Sep 17 00:00:00 2001 From: Jason Kulatunga Date: Sun, 25 Jul 2021 22:32:13 -0700 Subject: [PATCH] make sure data is persisted to DB. --- .../backend/pkg/database/scrutiny_repository.go | 8 -------- .../models/measurements/smart_ata_attribute.go | 17 +++++++++++++++++ .../models/measurements/smart_nvme_attribute.go | 16 ++++++++++++++++ .../measurements/smart_scsci_attribute.go | 16 ++++++++++++++++ 4 files changed, 49 insertions(+), 8 deletions(-) diff --git a/webapp/backend/pkg/database/scrutiny_repository.go b/webapp/backend/pkg/database/scrutiny_repository.go index bcfa20b..58fc514 100644 --- a/webapp/backend/pkg/database/scrutiny_repository.go +++ b/webapp/backend/pkg/database/scrutiny_repository.go @@ -446,11 +446,3 @@ func (sr *scrutinyRepository) GetSummary(ctx context.Context) (map[string]*model return summaries, nil } - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Process Thresholds -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -func (sr *scrutinyRepository) ProcessSmartAttributeThresholds() { - -} diff --git a/webapp/backend/pkg/models/measurements/smart_ata_attribute.go b/webapp/backend/pkg/models/measurements/smart_ata_attribute.go index 6481b4f..230c124 100644 --- a/webapp/backend/pkg/models/measurements/smart_ata_attribute.go +++ b/webapp/backend/pkg/models/measurements/smart_ata_attribute.go @@ -42,6 +42,12 @@ func (sa *SmartAtaAttribute) Flatten() map[string]interface{} { fmt.Sprintf("attr.%s.raw_value", idString): sa.RawValue, fmt.Sprintf("attr.%s.raw_string", idString): sa.RawString, fmt.Sprintf("attr.%s.when_failed", idString): sa.WhenFailed, + + //Generated Data + fmt.Sprintf("attr.%s.transformed_value", idString): sa.TransformedValue, + fmt.Sprintf("attr.%s.status", idString): sa.Status, + fmt.Sprintf("attr.%s.status_reason", idString): sa.StatusReason, + fmt.Sprintf("attr.%s.failure_rate", idString): sa.FailureRate, } } func (sa *SmartAtaAttribute) Inflate(key string, val interface{}) { @@ -70,6 +76,17 @@ func (sa *SmartAtaAttribute) Inflate(key string, val interface{}) { sa.RawString = val.(string) case "when_failed": sa.WhenFailed = val.(string) + + //generated + case "transformed_value": + sa.TransformedValue = val.(int64) + case "status": + sa.Status = val.(string) + case "status_reason": + sa.StatusReason = val.(string) + case "failure_rate": + sa.FailureRate = val.(float64) + } } diff --git a/webapp/backend/pkg/models/measurements/smart_nvme_attribute.go b/webapp/backend/pkg/models/measurements/smart_nvme_attribute.go index 80f1687..0320824 100644 --- a/webapp/backend/pkg/models/measurements/smart_nvme_attribute.go +++ b/webapp/backend/pkg/models/measurements/smart_nvme_attribute.go @@ -29,6 +29,12 @@ func (sa *SmartNvmeAttribute) Flatten() map[string]interface{} { fmt.Sprintf("attr.%s.name", sa.AttributeId): sa.Name, fmt.Sprintf("attr.%s.value", sa.AttributeId): sa.Value, fmt.Sprintf("attr.%s.thresh", sa.AttributeId): sa.Threshold, + + //Generated Data + fmt.Sprintf("attr.%s.transformed_value", sa.AttributeId): sa.TransformedValue, + fmt.Sprintf("attr.%s.status", sa.AttributeId): sa.Status, + fmt.Sprintf("attr.%s.status_reason", sa.AttributeId): sa.StatusReason, + fmt.Sprintf("attr.%s.failure_rate", sa.AttributeId): sa.FailureRate, } } func (sa *SmartNvmeAttribute) Inflate(key string, val interface{}) { @@ -47,6 +53,16 @@ func (sa *SmartNvmeAttribute) Inflate(key string, val interface{}) { sa.Value = val.(int64) case "thresh": sa.Threshold = val.(int64) + + //generated + case "transformed_value": + sa.TransformedValue = val.(int64) + case "status": + sa.Status = val.(string) + case "status_reason": + sa.StatusReason = val.(string) + case "failure_rate": + sa.FailureRate = val.(float64) } } diff --git a/webapp/backend/pkg/models/measurements/smart_scsci_attribute.go b/webapp/backend/pkg/models/measurements/smart_scsci_attribute.go index d692cef..a2f1ea1 100644 --- a/webapp/backend/pkg/models/measurements/smart_scsci_attribute.go +++ b/webapp/backend/pkg/models/measurements/smart_scsci_attribute.go @@ -29,6 +29,12 @@ func (sa *SmartScsiAttribute) Flatten() map[string]interface{} { fmt.Sprintf("attr.%s.name", sa.AttributeId): sa.Name, fmt.Sprintf("attr.%s.value", sa.AttributeId): sa.Value, fmt.Sprintf("attr.%s.thresh", sa.AttributeId): sa.Threshold, + + //Generated Data + fmt.Sprintf("attr.%s.transformed_value", sa.AttributeId): sa.TransformedValue, + fmt.Sprintf("attr.%s.status", sa.AttributeId): sa.Status, + fmt.Sprintf("attr.%s.status_reason", sa.AttributeId): sa.StatusReason, + fmt.Sprintf("attr.%s.failure_rate", sa.AttributeId): sa.FailureRate, } } func (sa *SmartScsiAttribute) Inflate(key string, val interface{}) { @@ -47,6 +53,16 @@ func (sa *SmartScsiAttribute) Inflate(key string, val interface{}) { sa.Value = val.(int64) case "thresh": sa.Threshold = val.(int64) + + //generated + case "transformed_value": + sa.TransformedValue = val.(int64) + case "status": + sa.Status = val.(string) + case "status_reason": + sa.StatusReason = val.(string) + case "failure_rate": + sa.FailureRate = val.(float64) } }