Skip to content

Commit db81681

Browse files
committed
dont query for costs if len(terms) < 2
1 parent 30d9c4c commit db81681

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

autocomplete/autocomplete.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,12 @@ func (h *Handler) requestExpr(r *http.Request, tcq *finder.TagCountQuerier, from
116116
if err != nil {
117117
return wr, pw, usedTags, err
118118
}
119+
if tagValuesCosts != nil {
120+
finder.SetCosts(terms, tagValuesCosts)
121+
} else if len(h.config.ClickHouse.TaggedCosts) != 0 {
122+
finder.SetCosts(terms, h.config.ClickHouse.TaggedCosts)
123+
}
119124

120-
finder.SetCosts(terms, tagValuesCosts)
121125
}
122126

123127
finder.SortTaggedTermsByCost(terms)

finder/tags_count_querier.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ func NewTagCountQuerier(url, table string, opts clickhouse.Options, useCarbonBeh
3838
}
3939

4040
func (tcq *TagCountQuerier) GetCostsFromCountTable(ctx context.Context, terms []TaggedTerm, from int64, until int64) (map[string]*config.Costs, error) {
41+
if len(terms) < 2 {
42+
return nil, nil
43+
}
44+
4145
w := where.New()
4246
eqTermCount := 0
4347

0 commit comments

Comments
 (0)