Commit a4a2e35b by utkarshcmu

Verified interval format function and gofmt check

parent 2088363b
...@@ -9,9 +9,9 @@ import ( ...@@ -9,9 +9,9 @@ import (
"net/http" "net/http"
"net/url" "net/url"
"path" "path"
"regexp"
"strings" "strings"
"time" "time"
"regexp"
"golang.org/x/net/context/ctxhttp" "golang.org/x/net/context/ctxhttp"
...@@ -153,15 +153,16 @@ func formatTimeRange(input string) string { ...@@ -153,15 +153,16 @@ func formatTimeRange(input string) string {
} }
func fixIntervalFormat(target string) string { func fixIntervalFormat(target string) string {
rMinute := regexp.MustCompile("'(\\d+)m'") rMinute := regexp.MustCompile(`'(\d+)m'`)
rMin := regexp.MustCompile("m") rMin := regexp.MustCompile("m")
target = rMinute.ReplaceAllStringFunc(target, func(m string) string { target = rMinute.ReplaceAllStringFunc(target, func(m string) string {
return rMin.ReplaceAllString(m, "min") return rMin.ReplaceAllString(m, "min")
}) })
rMonth := regexp.MustCompile("'(\\d+)M'") rMonth := regexp.MustCompile(`'(\d+)M'`)
rMon := regexp.MustCompile("M") rMon := regexp.MustCompile("M")
target = rMonth.ReplaceAllStringFunc(target, func(M string) string { target = rMonth.ReplaceAllStringFunc(target, func(M string) string {
return rMon.ReplaceAllString(M, "mon") return rMon.ReplaceAllString(M, "mon")
}) })
glog.Debug("Graphite Query", "target", target)
return target return target
} }
...@@ -6,7 +6,7 @@ import ( ...@@ -6,7 +6,7 @@ import (
) )
func TestGraphiteFunctions(t *testing.T) { func TestGraphiteFunctions(t *testing.T) {
Convey("Testing Graphite Executor", t, func() { Convey("Testing Graphite Functions", t, func() {
Convey("formatting time range for now", func() { Convey("formatting time range for now", func() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment