Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Contributors graph #847
Implement contributor graphs: https://github.com/go-gitea/gitea/graphs/contributors
I would like to start working on this feature, if no one is already on it (yeah @lafriks, I learned my lesson,
I would probably need some assistance every now and then, e.g. on how to decide about server or client side rendering, what charting library to use etc.
Let's start by taking apart existing solutions to identify required data and possible data structure.
API endpoint for contibutions data is
The returned JSON data is basically a list of objects (each representing one contributor) sorted least contributions first, most contributions last:
The structure is roughly similar to the one documented here and looks like this:
Each member of the
All that information is used to build these cards:
The big contributions graph obviously can be built by adding up the stats from each user of a week
GitLab CE is Open Source, so we have the relevant files:
API endpoint is
The returned JSON data is much simpler:
Each member of the array represents one commit, sorted latest commit first, initial commit last. The structure looks as follows:
If a user made multiple commits on the same day, there will simply be duplicate entries with the same user information and date, one for each commit.
The per-user tiles will contain less information than on GitHub, the plotting is done by taking the number of commits for one day, X-Axis is time, Y-Axis number of commits. That is done for both the whole repo (ignoring username) and each user (taking all commit entries for a specific user on a specific day).
In both cases rendering is done client side, which has the great advantage of being able to build dynamic charts with zooming.
If it works with your general workflow here, I'd be fine with being assigned to this issue.
Some more thoughts on this. Constructive feedback is of course highly appreciated!
Placing the page link on the UI
That should work fine, no need to restructure anything for now.
Speaking of links, the page should probably live at
Another idea, which I do not prefer, is putting the contributor graph(s) on the Activity page.
I did some DOM editing:
Now some quick CSS editing on the GitHub contributors chart for Gitea and merging the images:
That's a very rough idea of how it may look like, not taking individual per-user charts into account.
Ok folks, yet another update. I managed it to get to this state:
Click to expand:
Ideas for changes and improvements welcome - I'm exited so far! I fear the upcoming code review though
Sooo... here we go! Now it's the time for some external input, so please see below the images.
(gitea repo taken from GitHub)
Let me explain:
I fixed all of the issues noted in my last post, and I'm back to some performance issues. All stats from my dev machine:
The contributors page of the Gitea blog repo takes 1.1s to load, which is probably fine (Page: 1090ms Template: 7ms)
The one for the gitea main repo took 1min 14s and reports Page: 74443ms Template: 47ms. It has nine years of history and almost 7k commits, though.
Possible improvements: the gitea repo contributor page ends up with 602 user cards, I believe GitHub cuts off at 100. See https://github.com/go-gitea/gitea/graphs/contributors.
What do you think about that? As the charts become less useful with very few changes/commits because of the fixed Y-Axis, should we either only show top X contributors or maybe don't generate charts for more than e.g. 100 contributors?
Since the whole commit history will be traversed each time the page is visited, we can probably as well improve the situation by caching the stats. No clue if that makes sense and how implementation would look like.
I had to clear the ServiceWorker's cache for the changed CSS files to show up (normal cache refresh wouldn't work). What do I have to do here so it works OOTB?