adding duration key to smart attributes api endpoint

This commit is contained in:
Jason Kulatunga
2022-04-29 15:26:15 -07:00
parent f60636a6aa
commit 0a9d364aea
4 changed files with 175 additions and 94 deletions
@@ -19,7 +19,17 @@ func GetDeviceDetails(c *gin.Context) {
return
}
smartResults, err := deviceRepo.GetSmartAttributeHistory(c, c.Param("wwn"), "", nil)
durationKey, exists := c.GetQuery("duration_key")
if !exists {
durationKey = "forever"
}
smartResults, err := deviceRepo.GetSmartAttributeHistory(c, c.Param("wwn"), durationKey, nil)
if err != nil {
logger.Errorln("An error occurred while retrieving device smart results", err)
c.JSON(http.StatusInternalServerError, gin.H{"success": false})
return
}
var deviceMetadata interface{}
if device.IsAta() {