未验证 提交 38e060f7 编写于 作者: Y yubo 提交者: GitHub

When the time exceeds the limit, adjust the end time (#409)

上级 227652ec
......@@ -114,18 +114,19 @@ func xcludeResp(iter ident.TagIterator) *dataobj.XcludeResp {
return ret
}
func aggregateResp(data []*dataobj.TsdbQueryResponse, opts dataobj.QueryDataForUI) []*dataobj.TsdbQueryResponse {
if len(data) < 2 {
return data
}
// resample the data
func resampleResp(data []*dataobj.TsdbQueryResponse, opts dataobj.QueryDataForUI) []*dataobj.TsdbQueryResponse {
for _, v := range data {
if len(v.Values) <= MAX_PONINTS {
continue
}
v.Values = resample(v.Values, opts.Start, opts.End, int64(opts.Step), opts.ConsolFunc)
}
return data
}
func aggregateResp(data []*dataobj.TsdbQueryResponse, opts dataobj.QueryDataForUI) []*dataobj.TsdbQueryResponse {
// aggregateResp
if opts.AggrFunc == "" {
if len(data) < 2 || opts.AggrFunc == "" {
return data
}
......@@ -188,6 +189,7 @@ func aggregateResp(data []*dataobj.TsdbQueryResponse, opts dataobj.QueryDataForU
}
func resample(data []*dataobj.RRDData, start, end, step int64, consolFunc string) []*dataobj.RRDData {
l := int((end - start) / step)
if l <= 0 {
return []*dataobj.RRDData{}
......
......@@ -155,6 +155,8 @@ func (p *Client) QueryDataForUI(input dataobj.QueryDataForUI) []*dataobj.TsdbQue
return nil
}
ret = resampleResp(ret, input)
return aggregateResp(ret, input)
}
......@@ -484,9 +486,8 @@ func (cfg M3dbSection) validateQueryDataForUI(in *dataobj.QueryDataForUI) (err e
}
if cfg.DaysLimit > 0 {
if t := in.End - cfg.timeLimit; in.Start < t {
// return fmt.Errorf("query time reange in invalid, daysLimit(%d/%d)", days, cfg.DaysLimit)
in.Start = t
if t := in.Start + cfg.timeLimit; in.End > t {
in.End = t
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册