GWM : filter issue
This commit is contained in:
parent
50ba99ecf1
commit
130a7f17c8
7
main.go
7
main.go
@ -599,7 +599,7 @@ func main() {
|
||||
keyToFilter := record.GetString("unset_key")
|
||||
valueToExclude := record.GetString("unset_value")
|
||||
if keyToFilter == "" || valueToExclude == "" {
|
||||
fmt.Println("unset_key or unset_value is empty. Skipping processing.")
|
||||
// fmt.Println("unset_key or unset_value is empty. Skipping processing.")
|
||||
} else {
|
||||
// Filter the data dynamically and update chartData
|
||||
chartData = filterDynamicChartData(chartData, keyToFilter, valueToExclude)
|
||||
@ -651,6 +651,7 @@ func main() {
|
||||
"tab_order": record.GetString("tab_order"),
|
||||
"chart_type_json": record.Get("chart_type_json"),
|
||||
"card_full_length": record.Get("card_full_length"),
|
||||
"chart_bar_color": record.Get("chart_bar_color"),
|
||||
}
|
||||
|
||||
var cRes []utils.Observation
|
||||
@ -1678,8 +1679,8 @@ func main() {
|
||||
}()
|
||||
|
||||
// Start your custom HTTP server on port 8091
|
||||
log.Println("Starting custom HTTP server on :8091")
|
||||
if err := http.ListenAndServe(":8091", nil); err != nil {
|
||||
log.Println("Starting custom HTTP server on :9091")
|
||||
if err := http.ListenAndServe(":9091", nil); err != nil {
|
||||
log.Fatal("Failed to start server: ", err)
|
||||
}
|
||||
}
|
||||
|
||||
BIN
pb_data/logs.db
BIN
pb_data/logs.db
Binary file not shown.
@ -46,16 +46,17 @@ func CardCalculation(data []Observation, req CardCalculationRequest) (map[string
|
||||
// Convert RecodeIndex to an integer
|
||||
index, err := strconv.Atoi(req.RecodeIndex)
|
||||
if err != nil || index < 0 || index >= len(data) {
|
||||
return nil, errors.New("invalid record index")
|
||||
// return nil, errors.New("invalid record index")
|
||||
selectedData = []Observation{}
|
||||
} else {
|
||||
selectedData = []Observation{data[index]}
|
||||
}
|
||||
// Select only the requested index record
|
||||
selectedData = []Observation{data[index]}
|
||||
|
||||
} else {
|
||||
// Determine the number of records to use
|
||||
|
||||
if req.RecordCount == "all" {
|
||||
if len(data) >= 0 {
|
||||
if len(data) > 0 {
|
||||
selectedData = data
|
||||
} else {
|
||||
selectedData = []Observation{}
|
||||
@ -68,7 +69,7 @@ func CardCalculation(data []Observation, req CardCalculationRequest) (map[string
|
||||
}
|
||||
} else if req.RecordCount == "second_pair" {
|
||||
if len(data) >= 3 {
|
||||
selectedData = data[:2]
|
||||
selectedData = data[1:3]
|
||||
} else {
|
||||
selectedData = []Observation{}
|
||||
}
|
||||
@ -76,10 +77,13 @@ func CardCalculation(data []Observation, req CardCalculationRequest) (map[string
|
||||
n := len(data) // array leangth
|
||||
var err error
|
||||
n, err = strconv.Atoi(req.RecordCount)
|
||||
if err != nil || n > len(data) {
|
||||
return nil, errors.New("invalid record count")
|
||||
if err != nil || n >= len(data) {
|
||||
// return nil, errors.New("invalid record count");
|
||||
selectedData = []Observation{}
|
||||
} else {
|
||||
selectedData = data[:n]
|
||||
}
|
||||
selectedData = data[:n]
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user