Skip to content

Fill out the Contribution Analytics GraphQL App

Alex Pennells requested to merge contribution-analytics-graphql-app into master

What does this MR do and why?

Related issue: #376001 (closed)

Restores the content from !108273 (merged) which was reverted. GraphQL pagination still needs to be completed before this reaches feature parity with the legacy app.

This change is behind the contribution_analytics_graphql feature flag.


The description for the Pushes chart had to be updated, since we no longer have the total commit count metric. This wasn't added to GraphQL due to efficiency concerns, so it was removed from the description line

- 1234 pushes, more than 23456 commits by 78 contributors.
+ 1234 pushes by 78 contributors.

Screenshots or screen recordings

Loading Screenshot_2023-01-17_at_3.34.54_PM
Error Screenshot_2023-01-17_at_3.35.10_PM
Pushes Screenshot_2023-01-17_at_3.07.50_PM
MRs Screenshot_2023-01-17_at_3.08.05_PM
Issues Screenshot_2023-01-17_at_3.08.19_PM
Table Screenshot_2023-01-17_at_3.08.44_PM
Table (Mobile) Screenshot_2023-01-17_at_3.09.20_PM

How to set up and validate locally

  1. Enable the contribution_analytics_graphql feature flag.
  2. Visit any group contribution analytics page such as http://gdk.test:3000/groups/flightjs/-/contribution_analytics
  3. Validate the charts/table work as expected

Setting up analytics data

Your page may look empty, so to test easily you can mock the GraphQL response by replacing the Apollo update() callback:

-        return data.group?.contributions.nodes || [];
+        const getRandomInt = () => Math.floor(Math.random() * 1000);
+        const mockUser = () => ({
+          user: {
+            name: Math.random().toString(36).substr(2, 20),
+            webUrl: `http://gdk.test:3000/${Math.random().toString(36).substr(2, 5)}`
+          },
+          repoPushed: getRandomInt(),
+          mergeRequestsApproved: getRandomInt(),
+          mergeRequestsClosed: getRandomInt(),
+          mergeRequestsCreated: getRandomInt(),
+          mergeRequestsMerged: getRandomInt(),
+          issuesClosed: getRandomInt(),
+          issuesCreated: getRandomInt(),
+          totalEvents: getRandomInt(),
+        });
+        const result = [...Array(100)].map(() => mockUser());
+        return result;

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Brandon Labuschagne

Merge request reports