mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
pkg/tsdb: fix ineffassign isues
This commit is contained in:
parent
6b5854936d
commit
556219b192
@ -271,7 +271,7 @@ func parseQuery(model *simplejson.Json) (*CloudWatchQuery, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
period := 300
|
var period int
|
||||||
if regexp.MustCompile(`^\d+$`).Match([]byte(p)) {
|
if regexp.MustCompile(`^\d+$`).Match([]byte(p)) {
|
||||||
period, err = strconv.Atoi(p)
|
period, err = strconv.Atoi(p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -40,6 +40,9 @@ func (qp *InfluxdbQueryParser) Parse(model *simplejson.Json, dsInfo *models.Data
|
|||||||
}
|
}
|
||||||
|
|
||||||
parsedInterval, err := tsdb.GetIntervalFrom(dsInfo, model, time.Millisecond*1)
|
parsedInterval, err := tsdb.GetIntervalFrom(dsInfo, model, time.Millisecond*1)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
return &Query{
|
return &Query{
|
||||||
Measurement: measurement,
|
Measurement: measurement,
|
||||||
|
@ -62,9 +62,8 @@ func (query *Query) renderTags() []string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
textValue := ""
|
|
||||||
|
|
||||||
// quote value unless regex or number
|
// quote value unless regex or number
|
||||||
|
var textValue string
|
||||||
if tag.Operator == "=~" || tag.Operator == "!~" {
|
if tag.Operator == "=~" || tag.Operator == "!~" {
|
||||||
textValue = tag.Value
|
textValue = tag.Value
|
||||||
} else if tag.Operator == "<" || tag.Operator == ">" {
|
} else if tag.Operator == "<" || tag.Operator == ">" {
|
||||||
@ -107,7 +106,7 @@ func (query *Query) renderSelectors(queryContext *tsdb.TsdbQuery) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (query *Query) renderMeasurement() string {
|
func (query *Query) renderMeasurement() string {
|
||||||
policy := ""
|
var policy string
|
||||||
if query.Policy == "" || query.Policy == "default" {
|
if query.Policy == "" || query.Policy == "default" {
|
||||||
policy = ""
|
policy = ""
|
||||||
} else {
|
} else {
|
||||||
|
@ -83,6 +83,10 @@ func (e *OpenTsdbExecutor) createRequest(dsInfo *models.DataSource, data OpenTsd
|
|||||||
u.Path = path.Join(u.Path, "api/query")
|
u.Path = path.Join(u.Path, "api/query")
|
||||||
|
|
||||||
postData, err := json.Marshal(data)
|
postData, err := json.Marshal(data)
|
||||||
|
if err != nil {
|
||||||
|
plog.Info("Failed marshalling data", "error", err)
|
||||||
|
return nil, fmt.Errorf("Failed to create request. error: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
req, err := http.NewRequest(http.MethodPost, u.String(), strings.NewReader(string(postData)))
|
req, err := http.NewRequest(http.MethodPost, u.String(), strings.NewReader(string(postData)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user