fix: support zset score +inf/-inf #148

This commit is contained in:
Lykin 2024-02-14 13:54:09 +08:00
parent e271eafc9e
commit c0415fe23d
3 changed files with 13 additions and 4 deletions

View File

@ -9,6 +9,7 @@ import (
"fmt" "fmt"
"github.com/redis/go-redis/v9" "github.com/redis/go-redis/v9"
"github.com/wailsapp/wails/v2/pkg/runtime" "github.com/wailsapp/wails/v2/pkg/runtime"
"math"
"net/url" "net/url"
"os" "os"
"slices" "slices"
@ -998,10 +999,17 @@ func (b *browserService) GetKeyDetail(param types.KeyDetailParam) (resp types.JS
if doFilter && !strings.Contains(val, param.MatchPattern) { if doFilter && !strings.Contains(val, param.MatchPattern) {
continue continue
} }
items = append(items, types.ZSetEntryItem{ entry := types.ZSetEntryItem{
Score: z.Score,
Value: val, Value: val,
}) }
if math.IsInf(z.Score, 1) {
entry.ScoreStr = "+inf"
} else if math.IsInf(z.Score, -1) {
entry.ScoreStr = "-inf"
} else {
entry.Score = z.Score
}
items = append(items, entry)
if doConvert { if doConvert {
if dv, _, _ := convutil.ConvertTo(val, param.Decode, param.Format, decoder); dv != val { if dv, _, _ := convutil.ConvertTo(val, param.Decode, param.Format, decoder); dv != val {
items[len(items)-1].DisplayValue = dv items[len(items)-1].DisplayValue = dv

View File

@ -31,6 +31,7 @@ type SetEntryItem struct {
type ZSetEntryItem struct { type ZSetEntryItem struct {
Score float64 `json:"s"` Score float64 `json:"s"`
ScoreStr string `json:"ss,omitempty"`
Value string `json:"v"` Value string `json:"v"`
DisplayValue string `json:"dv,omitempty"` DisplayValue string `json:"dv,omitempty"`
} }

View File

@ -120,7 +120,7 @@ const scoreColumn = computed(() => ({
// return true // return true
// }, // },
render: (row) => { render: (row) => {
return row.s return row.ss || row.s
}, },
})) }))