Skip to content

Setup controller and routing for group MR activity report page

Related Issue: #217545 (closed)

High level overview

  1. Create a new namespace within global EE::Analytics namesapce: Reports (EE only for now, require read_group_activity_analytics permission for now)
    • Note: there might be FOSS reports in the future. MR activity is an EE feature at the moment.
  2. Setup a route and a basic controller (Analytics::Reports::PagesController): https://gitlab.com/-/analytics/report_pages/#/:report_id
    • Put the controller behind a feature flag: report_pages_#{report_id}
  3. Provide a controller action show that responds with html.
  4. Implement API endpoint for getting the chart configuration: API::Reports::Chart
    • /api/v4/analytics/reports/:report_id/chart
    • Return the dummy payload defined in: Chart configuration object
  5. Implement API endpoints for getting the series data: API::Reports::Series
    • /api/v4/analytics/reports/:report_id/chart/:series_id
    • Return the dummy payload defined in: Example series API payload

Example YAML definition (just for context)

recent_merge_requests_by_group:
  title: Recent Issues (90 days)
  chart:
    type: bar
    series:
      - id: open_merge_requests
        title: Merge Requests
        data_retrieval: Metrics::InsightsQuery
        data_retrieval_options: 
          issuable_type: merge_request 
          issuable_state: opened 
          group_by: week 
          period_limit: 12

Chart configuration object

This config will be exposed to the FE via HTML data attributes (on the first request). This is a subset of the YAML file. Data retrieval options are not required on the FE since we have the id attribute for the series.

{ 
  "id": "recent_merge_requests_by_group",
  "title": "Recent Issues (90 days)",
  "chart": {
    "type": "bar",
    "series": [
      {
        "id": "open_merge_requests",
        "title": "Merge requests"
      }
    ]
  }
}

Example series API payload

  • /api/v4/analytics/reports/:report_id/chart/:series_id
  • With parameters: /api/v4/analytics/reports/recent_merge_requests_by_group/chart/open_merge_requests
// Same as Insights endpoint
{
  "labels": [
    "label1",
    "label2",
    "label3"
  ],
  "datasets": [
    {
       "label": "Series 1",
       "data": [
         1,
         2,
         3
       ]
    }
  ]
}
Edited by Adam Hegyi