-
Task
-
Resolution: Unresolved
-
Normal
-
None
-
None
-
None
-
Quality / Stability / Reliability
-
False
-
-
False
-
Green
-
-
-
No
-
Rox Sprint 4.11B, Rox Sprint 4.11C
There are some fields ListAlert returns that are not easily made to columns. So I thought maybe first I would reduce usage of ListAlert. Numerous graphql resolvers use ListAlert to simply count policies by category. That is a lot of overhead to simply return a set of counts the database can do.
func mapListAlertsToPolicySeverityCount(alerts []*storage.ListAlert) *PolicyCounterResolver {
counter := &PolicyCounterResolver{}
policyIDs := set.NewStringSet()
for _, alert := range alerts {
if alert.GetState() != storage.ViolationState_ACTIVE {
continue
}
policy := alert.GetPolicy()
if !policyIDs.Add(policy.GetId()) {
continue
}
incPolicyCounter(counter, policy.GetSeverity())
}
return counter
}
Create a view that will enable us to replace these functions and simply return those numbers from the database.