mirror of
https://github.com/grafana/grafana.git
synced 2025-02-09 23:16:16 -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)) {
|
||||
period, err = strconv.Atoi(p)
|
||||
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)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &Query{
|
||||
Measurement: measurement,
|
||||
|
@ -62,9 +62,8 @@ func (query *Query) renderTags() []string {
|
||||
}
|
||||
}
|
||||
|
||||
textValue := ""
|
||||
|
||||
// quote value unless regex or number
|
||||
var textValue string
|
||||
if tag.Operator == "=~" || tag.Operator == "!~" {
|
||||
textValue = tag.Value
|
||||
} else if tag.Operator == "<" || tag.Operator == ">" {
|
||||
@ -107,7 +106,7 @@ func (query *Query) renderSelectors(queryContext *tsdb.TsdbQuery) string {
|
||||
}
|
||||
|
||||
func (query *Query) renderMeasurement() string {
|
||||
policy := ""
|
||||
var policy string
|
||||
if query.Policy == "" || query.Policy == "default" {
|
||||
policy = ""
|
||||
} else {
|
||||
|
@ -83,6 +83,10 @@ func (e *OpenTsdbExecutor) createRequest(dsInfo *models.DataSource, data OpenTsd
|
||||
u.Path = path.Join(u.Path, "api/query")
|
||||
|
||||
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)))
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user