Browse Source

Fix decisions list with --no-simu flag (#1482)

* Fix decisions list with --no-simu flag
AlteredCoder 3 years ago
parent
commit
a645c928d4
1 changed files with 4 additions and 2 deletions
  1. 4 2
      pkg/database/alerts.go

+ 4 - 2
pkg/database/alerts.go

@@ -558,7 +558,6 @@ func BuildAlertRequestFromFilter(alerts *ent.AlertQuery, filter map[string][]str
 		if v[0] == "false" {
 			alerts = alerts.Where(alert.SimulatedEQ(false))
 		}
-		delete(filter, "simulated")
 	}
 
 	if _, ok := filter["origin"]; ok {
@@ -642,6 +641,8 @@ func BuildAlertRequestFromFilter(alerts *ent.AlertQuery, filter map[string][]str
 			continue
 		case "sort":
 			continue
+		case "simulated":
+			continue
 		default:
 			return nil, errors.Wrapf(InvalidFilter, "Filter parameter '%s' is unknown (=%s)", param, value[0])
 		}
@@ -778,10 +779,11 @@ func (c *Client) QueryAlertWithFilter(filter map[string][]string) ([]*ent.Alert,
 				break
 			}
 			ret = append(ret, result[0:diff]...)
+
 		} else {
 			ret = append(ret, result...)
 		}
-		if len(ret) == limit || len(ret) == 0 {
+		if len(ret) == limit || len(ret) == 0 || len(ret) < paginationSize {
 			c.Log.Debugf("Pagination done len(ret) = %d", len(ret))
 			break
 		}