Skip to content

Commit

Permalink
fix: sorting len
Browse files Browse the repository at this point in the history
  • Loading branch information
Majorfi committed Nov 10, 2024
1 parent c715076 commit 6a36ad6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cmd/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/gin-gonic/gin"
"github.com/patrickmn/go-cache"
"github.com/yearn/ydaemon/common/logs"
"github.com/yearn/ydaemon/external/vaults"
)

Expand All @@ -16,10 +17,12 @@ type GetCustomVaults func(c *gin.Context) []vaults.TRotkiVaults
func CacheSimplifiedVaults(cachingStore *cache.Cache, expire time.Duration, handle GetSimplifiedVaults) gin.HandlerFunc {
return func(c *gin.Context) {
if result, found := cachingStore.Get(c.Request.URL.String()); found && result != nil && len(result.([]vaults.TSimplifiedExternalVault)) > 0 {
logs.Info(`Cache hit with`, len(result.([]vaults.TSimplifiedExternalVault)), `vaults`)
c.JSON(http.StatusOK, result)
} else {
result := handle(c)
cachingStore.Set(c.Request.URL.String(), result, expire)
logs.Info(`Cache miss with`, len(result), `vaults`)
c.JSON(http.StatusOK, result)
}
}
Expand Down
1 change: 1 addition & 0 deletions external/vaults/prepare.getVaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ func getVaults(
}
newVault, err := NewVault().AssignTVault(currentVault)
if err != nil {
logs.Error(`Impossible to assign TVault`, err)
continue
}
if migrable == `none` && (newVault.Details.IsHidden || newVault.Details.IsRetired) && hideAlways {
Expand Down

0 comments on commit 6a36ad6

Please sign in to comment.