Skip to content

admin-analytics: optimize user management data layer

Administrator requested to merge erzhtor/add-user-administration-caching into main

Created by: erzhtor

It seems that because user management SQL queries use join large event_logs and users tables to create a full in-memory table, the GQL API response is slow and even fails with a time-out exception.

This PR:

  • Extracts query logic into separate internal/users/stats.go file
  • Adds aggregated_user_statistics table which is updated/seeded every 12 hours
  • Adds SiteUser.displayName GQL field

Test plan

query UsersManagementUsersList {
  site {
    users(query: null, lastActivePeriod: THIS_MONTH) {
      totalCount
      nodes(first: 25, orderBy: EVENTS_COUNT, descending: true) {
        id
        username
        email
        siteAdmin
        eventsCount
        createdAt
        lastActiveAt
        deletedAt
      }
    }
  }
}

Merge request reports

Loading