Expose code suggestion events on GraphQL

What does this MR do and why?

Expose code suggestion events data on GraphQL for groups and projects. In this first iteration, the endpoint will only work for root level groups, the functionality for subgroups and projects will be implemented after #490601 (closed) which will allow to filter events by namespace.

On this MR we consider that a code suggestion event belongs to a root group if a user did contribute to any child project by pushing code. For performance reasons the strategy to fetch group contributors is different between CH and Postgresql

Limitation when CH is not available

Temporarily we need to fetch contributors, users which pushed code, from events table. For performance reasons we limit the query to the last 7 days.

related to #477231 (closed)

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

How to set up and validate locally

  1. Enable ClickHouse locally by following these instructions
  2. Run FILTER=ai_usage_stats bundle exec rake db:seed_fu
  3. Pick any root-level group path which has child projects and run the following query:
query test {
  group(fullPath: "ROOT_GROUP_PATH") {
    id
    aiUsageData {
      codeSuggestionEvents {
        nodes {
          user {
            id
          }
          event
          timestamp
          language
          suggestionSize
          uniqueTrackingId
        }
      }
    }
  }
}
Edited by Felipe Cardozo

Merge request reports

Loading