Skip to content

Commit 5a3832c

Browse files
fix
1 parent 8015da1 commit 5a3832c

4 files changed

Lines changed: 11 additions & 12 deletions

File tree

internal/api/seqapi/v1/grpc/search_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ func TestSearch(t *testing.T) {
8383
req: &seqapi.SearchRequest{
8484
Limit: 10,
8585
},
86-
cfg: test.SetCfgDefaults(config.SeqAPI{
86+
cfg: config.SeqAPI{
8787
SeqAPIOptions: &config.SeqAPIOptions{
8888
MaxSearchLimit: 5,
8989
},
90-
}),
90+
},
9191
apiErr: true,
9292
},
9393
{

internal/api/seqapi/v1/http/search_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,22 +288,22 @@ func TestServeSearch(t *testing.T) {
288288
name: "err_search_limit_max",
289289
reqBody: formatReqBody(10, 0, false, "", nil, ""),
290290
wantStatus: http.StatusBadRequest,
291-
cfg: test.SetCfgDefaults(config.SeqAPI{
291+
cfg: config.SeqAPI{
292292
SeqAPIOptions: &config.SeqAPIOptions{
293293
MaxSearchLimit: 5,
294294
},
295-
}),
295+
},
296296
},
297297
{
298298
name: "err_aggs_limit_max",
299299
reqBody: formatReqBody(3, 0, false, "", aggregationQueries{{}, {}, {}}, ""),
300300
wantStatus: http.StatusBadRequest,
301-
cfg: test.SetCfgDefaults(config.SeqAPI{
301+
cfg: config.SeqAPI{
302302
SeqAPIOptions: &config.SeqAPIOptions{
303303
MaxSearchLimit: 5,
304304
MaxAggregationsPerRequest: 2,
305305
},
306-
}),
306+
},
307307
}, {
308308
name: "err_offset_too_high",
309309
reqBody: formatReqBody(3, 11, false, "", nil, ""),

internal/api/seqapi/v1/http/start_async_search.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ func (a *API) serveStartAsyncSearch(w http.ResponseWriter, r *http.Request) {
4242
wr.Error(fmt.Errorf("failed to parse search request: %w", err), http.StatusBadRequest)
4343
return
4444
}
45+
4546
parsedRetention, err := time.ParseDuration(httpReq.Retention)
4647
if err != nil {
4748
wr.Error(fmt.Errorf("failed to parse retention: %w", err), http.StatusBadRequest)

internal/pkg/service/async_searches/service.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,7 @@ func (s *Service) GetAsyncSearchesList(
185185

186186
for _, as := range resp.Searches {
187187
as.OwnerName = ownerNameByID[as.SearchId]
188-
if trimmedQuery, ok := s.trimQueryToLimit(as.Request.Query, s.cfg.ListQueryLengthLimit); ok {
189-
as.Request.Query = trimmedQuery + "..."
190-
}
188+
as.Request.Query = s.trimQueryToLimit(as.Request.Query, s.cfg.ListQueryLengthLimit)
191189
}
192190

193191
return resp, nil
@@ -219,13 +217,13 @@ func (s *Service) deleteExpiredAsyncSearches(ctx context.Context) {
219217
}
220218
}
221219

222-
func (s *Service) trimQueryToLimit(query string, limit int) (string, bool) {
220+
func (s *Service) trimQueryToLimit(query string, limit int) string {
223221
count := 0
224222
for i := range query {
225223
if count == limit {
226-
return query[:i], true
224+
return query[:i] + "..."
227225
}
228226
count++
229227
}
230-
return query, false
228+
return query
231229
}

0 commit comments

Comments
 (0)