Skip to content

Commit

Permalink
fix(query): set the From and To timestamps if specified (#143)
Browse files Browse the repository at this point in the history
  • Loading branch information
aybabtme authored Dec 22, 2024
1 parent 28f4448 commit 06d4c3a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions internal/localsvc/svc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 06d4c3a

Please sign in to comment.