Uploaded image for project: 'Red Hat Advanced Cluster Security'
  1. Red Hat Advanced Cluster Security
  2. ROX-33251

Update graphql resolvers to use count query instead of SearchListAlerts

    • Icon: Task Task
    • Resolution: Unresolved
    • Icon: Normal Normal
    • None
    • None
    • None
    • 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.

              rh-ee-dashrews David Shrewsberry
              rh-ee-dashrews David Shrewsberry
              ACS Core Workflows
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated: