mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Elasticsearch: Fix histogram fields to be filterale when processed trough backend (#64514)
* Elasticsearch: Fix histogram fields to be filterale when processed trough backend * Simplify test and reuse logic
This commit is contained in:
parent
abbae80b5e
commit
d6eea0c7b5
@ -732,14 +732,18 @@ func processAggregationDocs(esAgg *simplejson.Json, aggDef *BucketAgg, target *Q
|
||||
}
|
||||
|
||||
func extractDataField(name string, v interface{}) *data.Field {
|
||||
var field *data.Field
|
||||
switch v.(type) {
|
||||
case *string:
|
||||
return data.NewField(name, nil, []*string{})
|
||||
field = data.NewField(name, nil, []*string{})
|
||||
case *float64:
|
||||
return data.NewField(name, nil, []*float64{})
|
||||
field = data.NewField(name, nil, []*float64{})
|
||||
default:
|
||||
return &data.Field{}
|
||||
field = &data.Field{}
|
||||
}
|
||||
isFilterable := true
|
||||
field.Config = &data.FieldConfig{Filterable: &isFilterable}
|
||||
return field
|
||||
}
|
||||
|
||||
func trimDatapoints(queryResult backend.DataResponse, target *Query) {
|
||||
|
@ -812,7 +812,8 @@ func TestHistogramSimple(t *testing.T) {
|
||||
|
||||
require.Len(t, result.response.Responses, 1)
|
||||
frames := result.response.Responses["A"].Frames
|
||||
// require.Len(t, frames, 3) // FIXME
|
||||
require.Len(t, frames, 1)
|
||||
requireFrameLength(t, frames[0], 3)
|
||||
|
||||
fields := frames[0].Fields
|
||||
require.Len(t, fields, 2)
|
||||
@ -822,14 +823,12 @@ func TestHistogramSimple(t *testing.T) {
|
||||
|
||||
require.Equal(t, "bytes", field1.Name)
|
||||
|
||||
// trueValue := true
|
||||
// filterableConfig := data.FieldConfig{Filterable: &trueValue}
|
||||
trueValue := true
|
||||
filterableConfig := data.FieldConfig{Filterable: &trueValue}
|
||||
|
||||
// we need to test that the only changed setting is `filterable`
|
||||
// require.Equal(t, filterableConfig, *field1.Config) // FIXME
|
||||
|
||||
require.Equal(t, filterableConfig, *field1.Config)
|
||||
require.Equal(t, "Count", field2.Name)
|
||||
|
||||
// we need to test that the fieldConfig is "empty"
|
||||
require.Nil(t, field2.Config)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user