@@ -658,7 +658,7 @@ func (c *Client) createAlertChunk(ctx context.Context, machineID string, owner *
658
658
if discardCount > 0 && len (decisions ) == 0 {
659
659
c .Log .Warningf ("dropping alert %s: all decisions invalid" , alertItem .UUID )
660
660
continue
661
- }
661
+ }
662
662
663
663
alertBuilder := c .Ent .Alert .
664
664
Create ().
@@ -845,6 +845,13 @@ func (c *Client) QueryAlertWithFilter(ctx context.Context, filter map[string][]s
845
845
return nil , errors .Wrapf (QueryFail , "pagination size: %d, offset: %d: %s" , paginationSize , offset , err )
846
846
}
847
847
848
+ if len (result ) == 0 { // no results, no need to try to paginate further
849
+ c .Log .Debugf ("Pagination done because no results found at offset %d | len(ret) %d" , offset , len (ret ))
850
+ break
851
+ }
852
+ log .Debugf ("QueryAlertWithFilter: pagination size %d, offset %d, got %d results" , paginationSize , offset , len (result ))
853
+ log .Debugf ("diff is %d, limit is %d" , limit - len (ret ), limit )
854
+
848
855
if diff := limit - len (ret ); diff < paginationSize {
849
856
if len (result ) < diff {
850
857
ret = append (ret , result ... )
@@ -858,7 +865,7 @@ func (c *Client) QueryAlertWithFilter(ctx context.Context, filter map[string][]s
858
865
ret = append (ret , result ... )
859
866
}
860
867
861
- if len (ret ) == limit || len (ret ) == 0 || len ( ret ) < paginationSize {
868
+ if len (ret ) == limit || len (result ) < paginationSize {
862
869
c .Log .Debugf ("Pagination done len(ret) = %d" , len (ret ))
863
870
break
864
871
}
0 commit comments