From 5b364b37101c92cd8b4cbe748667173549623b66 Mon Sep 17 00:00:00 2001 From: Antoine Grondin Date: Sun, 22 Dec 2024 18:54:51 +0900 Subject: [PATCH] fix(query): set the `From` and `To` timestamps if specified --- internal/localsvc/svc.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/internal/localsvc/svc.go b/internal/localsvc/svc.go index 775d23d..5313f32 100644 --- a/internal/localsvc/svc.go +++ b/internal/localsvc/svc.go @@ -274,15 +274,22 @@ func (svc *Service) SummarizeEvents(ctx context.Context, req *connect.Request[qr } func (svc *Service) WatchQuery(ctx context.Context, req *connect.Request[qrv1.WatchQueryRequest], stream *connect.ServerStream[qrv1.WatchQueryResponse]) error { query := req.Msg.GetQuery() - if query == nil { + if query == nil || query.Query == nil { if req.Msg.PlaintextQuery == nil { return connect.NewError(connect.CodeInvalidArgument, fmt.Errorf("need either a `query` object or a `plaintext_query` string")) } var err error - query, err = logql.Parse(req.Msg.PlaintextQuery.Query) + q, err := logql.Parse(req.Msg.PlaintextQuery.Query) if err != nil { return connect.NewError(connect.CodeInvalidArgument, fmt.Errorf("parsing `plaintext_query`: %v", err)) } + if query != nil && query.From != nil && q.From == nil { + q.From = query.From + } + if query != nil && query.To != nil && q.To == nil { + q.To = query.To + } + query = q } ll := svc.ll.With(