Live: labels column as default frame format (#33984)

* labels columns as default frame format

* update sdk

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
This commit is contained in:
Alexander Emelin
2021-05-13 11:01:20 +02:00
committed by GitHub
co-authored by Ryan McKinley
parent 7c153e2eb4
commit e97750b824
4 changed files with 37 additions and 7 deletions
+8 -4
View File
@@ -5,17 +5,21 @@ import (
"strings"
)
const (
unstableSchemaParam = "gf_live_unstable_schema"
frameFormatParam = "gf_live_frame_format"
)
// UnstableSchemaFromValues extracts unstable schema tip from url values.
func UnstableSchemaFromValues(values url.Values) bool {
key := "gf_live_unstable_schema"
return strings.ToLower(values.Get(key)) == "true" || values.Get(key) == "1"
return strings.ToLower(values.Get(unstableSchemaParam)) == "true" || values.Get(unstableSchemaParam) == "1"
}
// FrameFormatFromValues extracts frame format tip from url values.
func FrameFormatFromValues(values url.Values) string {
frameFormat := strings.ToLower(values.Get("gf_live_frame_format"))
frameFormat := strings.ToLower(values.Get(frameFormatParam))
if frameFormat == "" {
frameFormat = "wide"
frameFormat = "labels_column"
}
return frameFormat
}
+26
View File
@@ -0,0 +1,26 @@
package pushurl
import (
"net/url"
"testing"
"github.com/stretchr/testify/require"
)
func TestUnstableSchemaFromValues(t *testing.T) {
values := url.Values{}
require.False(t, UnstableSchemaFromValues(values))
values.Set(unstableSchemaParam, "yes")
require.False(t, UnstableSchemaFromValues(values))
values.Set(unstableSchemaParam, "true")
require.True(t, UnstableSchemaFromValues(values))
values.Set(unstableSchemaParam, "True")
require.True(t, UnstableSchemaFromValues(values))
}
func TestFrameFormatFromValues(t *testing.T) {
values := url.Values{}
require.Equal(t, "labels_column", FrameFormatFromValues(values))
values.Set(frameFormatParam, "wide")
require.Equal(t, "wide", FrameFormatFromValues(values))
}