mirror of
https://github.com/go-gitea/gitea.git
synced 2026-07-15 20:09:18 -05:00
Contributors graph #323
Closed
opened 2025-11-02 03:18:31 -06:00 by GiteaMirror
·
49 comments
No Branch/Tag Specified
main
release/v1.25
release/v1.24
release/v1.23
release/v1.22
release/v1.21
release/v1.20
release/v1.19
release/v1.18
release/v1.17
release/v1.16
release/v1.15
release/v1.14
release/v1.13
release/v1.12
release/v1.11
release/v1.10
release/v1.9
release/v1.8
v1.25.3
v1.25.2
v1.25.1
v1.25.0
v1.24.7
v1.25.0-rc0
v1.26.0-dev
v1.24.6
v1.24.5
v1.24.4
v1.24.3
v1.24.2
v1.24.1
v1.24.0
v1.23.8
v1.24.0-rc0
v1.25.0-dev
v1.23.7
v1.23.6
v1.23.5
v1.23.4
v1.23.3
v1.23.2
v1.23.1
v1.23.0
v1.23.0-rc0
v1.24.0-dev
v1.22.6
v1.22.5
v1.22.4
v1.22.3
v1.22.2
v1.22.1
v1.22.0
v1.23.0-dev
v1.22.0-rc1
v1.21.11
v1.22.0-rc0
v1.21.10
v1.21.9
v1.21.8
v1.21.7
v1.21.6
v1.21.5
v1.21.4
v1.21.3
v1.21.2
v1.20.6
v1.21.1
v1.21.0
v1.21.0-rc2
v1.21.0-rc1
v1.20.5
v1.22.0-dev
v1.21.0-rc0
v1.20.4
v1.20.3
v1.20.2
v1.20.1
v1.20.0
v1.19.4
v1.21.0-dev
v1.20.0-rc2
v1.20.0-rc1
v1.20.0-rc0
v1.19.3
v1.19.2
v1.19.1
v1.19.0
v1.19.0-rc1
v1.20.0-dev
v1.19.0-rc0
v1.18.5
v1.18.4
v1.18.3
v1.18.2
v1.18.1
v1.18.0
v1.17.4
v1.18.0-rc1
v1.19.0-dev
v1.18.0-rc0
v1.17.3
v1.17.2
v1.17.1
v1.17.0
v1.17.0-rc2
v1.16.9
v1.17.0-rc1
v1.18.0-dev
v1.16.8
v1.16.7
v1.16.6
v1.16.5
v1.16.4
v1.16.3
v1.16.2
v1.16.1
v1.16.0
v1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
v1.3.1
v1.3.0
v1.3.0-rc2
v1.3.0-rc1
v1.2.3
v1.2.2
v1.2.1
v1.2.0
v1.2.0-rc3
v1.2.0-rc2
v1.1.4
v1.2.0-rc1
v1.1.3
v1.1.2
v1.1.1
v1.1.0
v1.0.2
v1.0.1
v1.0.0
v0.9.99
Labels
Clear labels
$20
$250
$50
$500
backport/done
💎 Bounty
docs-update-needed
good first issue
hacktoberfest
issue/bounty
issue/confirmed
issue/critical
issue/duplicate
issue/needs-feedback
issue/not-a-bug
issue/regression
issue/stale
issue/workaround
lgtm/need 2
modifies/api
modifies/translation
outdated/backport/v1.18
outdated/theme/markdown
outdated/theme/timetracker
performance/bigrepo
performance/cpu
performance/memory
performance/speed
pr/breaking
proposal/accepted
proposal/rejected
pr/wip
pull-request
reviewed/wontfix
💰 Rewarded
skip-changelog
status/blocked
topic/accessibility
topic/api
topic/authentication
topic/build
topic/code-linting
topic/commit-signing
topic/content-rendering
topic/deployment
topic/distribution
topic/federation
topic/gitea-actions
topic/issues
topic/lfs
topic/mobile
topic/moderation
topic/packages
topic/pr
topic/projects
topic/repo
topic/repo-migration
topic/security
topic/theme
topic/ui
topic/ui-interaction
topic/ux
topic/webhooks
topic/wiki
type/bug
type/deprecation
type/docs
type/enhancement
type/feature
type/miscellaneous
type/proposal
type/question
type/refactoring
type/summary
type/testing
type/upstream
Mirrored from GitHub Pull Request
Milestone
No items
No Milestone
Projects
Clear projects
No project
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/gitea#323
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ShalokShalom on GitHub (Feb 5, 2017).
Implement contributor graphs: https://github.com/go-gitea/gitea/graphs/contributors
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
@bkcsoft commented on GitHub (Feb 6, 2017):
Is there a good graph-lib? In my opinion this can be rendered and cached server-side
@akuzia commented on GitHub (Dec 24, 2017):
Any progress?
@ghost commented on GitHub (Jun 2, 2018):
would be nice to have 🎉
@linusg commented on GitHub (Oct 2, 2018):
I would like to start working on this feature, if no one is already on it (yeah @lafriks, I learned my lesson,
+1is not constructive 😉).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.
I also basically don't know any Go but have good frontend knowledge so it should work, and everything has a first time, also I wanted to dive into hacking on Gitea some while ago 😄
@linusg commented on GitHub (Oct 2, 2018):
Let's start by taking apart existing solutions to identify required data and possible data structure.
GitHub
API endpoint for contibutions data is
https://github.com/<owner>/<repo>/graphs/contributors-data.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
"weeks"array is contructed has the following attributes:w- Start of the week, given as a Unix timestamp.a- Number of additionsd- Number of deletionsc- Number of commitsAll 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
n(0 <= n <= weeks since the repo exists) and plotting the cumulative value for each week.GitLab
GitLab CE is Open Source, so we have the relevant files:
API endpoint is
https://gitlab.com/<owner>/<repo>/graphs/master?format=json.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.
@linusg commented on GitHub (Oct 11, 2018):
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
https://git.example.com/<owner>/<repo>/contributors, that's how all the other links up there work.Another idea, which I do not prefer, is putting the contributor graph(s) on the Activity page.
I did some DOM editing:
I chose
octicon-organizationas the icon,octicon-graphmight work as well.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.
@ShalokShalom commented on GitHub (Oct 11, 2018):
Looks wonderful ^-^
@lunny commented on GitHub (Oct 12, 2018):
@linusg great! Go ahead!
@linusg commented on GitHub (Oct 12, 2018):
@lunny I'm kinda confused right now: Who is @Morlinest and what role will he play in this issue?
@Morlinest commented on GitHub (Oct 12, 2018):
It is probably a mistake or maybe he has some secret plans with me :D
@lunny commented on GitHub (Oct 12, 2018):
@linusg @Morlinest :( sorry. A mistake like what @Morlinest said. I want to assign this issue to @linusg but I found it cannot be assigned to non-maintainers and issue poster.
@linusg commented on GitHub (Oct 12, 2018):
Ok, thanks for clarification 😄
@Morlinest commented on GitHub (Oct 12, 2018):
Oh, so I will have to do it now :D
@linusg commented on GitHub (Jan 6, 2019):
Short heads-up for those interested: I wanted to work on this during the Christmas holidays, but couldn't find much time. I've created the basic stuff (page, routing etc.) and plan to continue working on it!
@ShalokShalom commented on GitHub (Jan 6, 2019):
Thanks a lot ^-^
@linusg commented on GitHub (Jan 7, 2019):
Ok folks, yet another update. I managed it to get to this state:
Click to expand:
Gitea vs GitHub (real-life example)
Dark
Details:
Issues left:
Contributors, which are not in the gitea DB (e.g. because the repo was imported) will not show up.✅Performance issues with bigger repositories. Edit: not performance, but HTTP 500 with the message "http: multiple response.WriteHeader calls" written to the console. Might be just me being a golang n00b.Removing the AM/PM stuff from the X-Axis (can be easily done via custom formatter)✅Fix the Y-Axis scale of user graphs, 1 commit should be half the height as 2 commits✅Proper dark theme support (CSS for above was tweaked in the dev tools)✅Possible enhancements:
Ideas for changes and improvements welcome - I'm exited so far! I fear the upcoming code review though 😄
@linusg commented on GitHub (Jan 8, 2019):
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:
Users who are not in the gitea users DB will be shown, but with no link to the profile, obv. Stats are calculated by Username (available is only "name" and "email" per each commit), that's why there's "Unknown", "Unknwon" and "无闻" vs only "Unknwon" in GitHub: The information, that this is all the same user is lost when cloning/importing the repo. I guess that's the best option available, thoughts?
GitHub compiles stats per week, I went with daily stats. Should this be changed?
That's the reason why the Y-Axis on GitHub ends at ~150 [commits per week] and the Gitea one at 52 [commits per day]. Also it makes the chart on Gitea appear with more "spikes". (interpolation isn't available as well)
GitHub excludes merge commits from the stats, I didn't implement anything of this kind (and don't know how hard distinguishing one from a normal commit would be). Do we want this feature?
Do you wish a separate color for the per-user charts?
What else do you think can be improved?
Performance:
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?
More screenshots, click to expand
@lunny commented on GitHub (Jan 9, 2019):
@linusg Great job!!! How about to let the work as a cronjob when the repository is big(i.e. over 1000 commits)? It can be run one or more days according the configuration. I think top 100 is enough, otherwise pagination is better.
@ghost commented on GitHub (Jan 9, 2019):
@linusg
Maybe you can use the default branch option instead of creating another option.
@stale[bot] commented on GitHub (Mar 10, 2019):
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.
@linusg commented on GitHub (Mar 10, 2019):
Nope, still working on this - someone might remove the
stalelabel!@bryanpedini commented on GitHub (Jun 16, 2019):
That's good news, hoping to see this feature coming soon!
Hyped to see charts and graphic data representation everywhere...
@linusg commented on GitHub (Jun 16, 2019):
Soon ™️
Time is definitely a problem for me... next to my basically non-existent knowledge of golang, haha.
I'm happy to see all the excitement (I'm excited too, wouldn't work on this otherwise!), but if you folks feel like this is not making progress fast enough (damn, it's been over half a year), I can make a PR with all the changes and someone else can help out?
@bryanpedini commented on GitHub (Jun 16, 2019):
😅
Naaah.. whoever cares of the time you take for a feature, if it is a very good and working feature?
IDK, maybe you can post your repo publicly here on GH so other people can PR your repo and get it working so than you can PR the official one and get that integrated
OR you can open a PR for a new branch on the official repo from which skilled and time willing people can fork and work and PR that instead, waiting for the branch to get merged into master of course...
@lunny commented on GitHub (Jun 17, 2019):
@linusg Please send a PR that maybe someone could help you when you are absent.
@a1012112796 commented on GitHub (May 5, 2020):
looking forward to this feature. Is it stale now ? .....Thanks
@mrenvoize commented on GitHub (Jun 17, 2020):
Any further news here?
@mrenvoize commented on GitHub (Oct 3, 2020):
Did a PR or branch ever get submitted here?
@lunny commented on GitHub (Oct 3, 2020):
I think not. @linusg
@linusg commented on GitHub (Oct 3, 2020):
I don't think I ever pushed my changes. Not even sure if I still have them - sorry!
@IzzySoft commented on GitHub (Feb 9, 2021):
So 4 years later: how do chances stand? @linusg did you find your changes? That looked already so promising!
@midischwarz12 commented on GitHub (Feb 24, 2022):
Any updates on this?
@new-mikha commented on GitHub (Mar 19, 2022):
Plus 1 to the question "any updates on this?"
Would be such a useful feature, please bring it on!
@sahinakkaya commented on GitHub (Jun 15, 2023):
I will try to implement this since no one seems to be working on it. I have zero experience with go but I think I will figure it out. Let's see how it goes 🤞
@sahinakkaya commented on GitHub (Jun 19, 2023):
I decided to use Chart.js to draw the graphs. Right now gitea repository looks like this:
There are still some work to do but before continuing I wanted to ask the maintainers if the Chart.js dependency is OK or not. If it is not ok which library should I use?
Any other feedback is also greatly appreciated :)
@sahinakkaya commented on GitHub (Jun 19, 2023):
@wxiaoguang @lunny @techknowlogick @silverwind
@lunny commented on GitHub (Jun 19, 2023):
Since it's under MIT license, I think it's acceptable. Is that library the best choice to draw the graph? But of course PRs are always welcome.
@sahinakkaya commented on GitHub (Jun 19, 2023):
@lunny These were my requirements:
Of course none of these requirements are hard requirements but they are nice to have. Chart.js supports all of them (last one available via an extension) If anyone have a simpler alternative in mind, I can take a look at that too.
@sahinakkaya commented on GitHub (Jun 19, 2023):
Another update (Help needed):
I copied the Activity page and replace the content with graphs. I think it looks OK except for the top section where it shows dates and period selection menu (they are left-overs from Activity page).
I obviously need to replace that top right menu with contribution type selection (commits, additions, deletions) however, I don't have any idea about how to handle it in a single page. The Activity page's menu redirects you to other endpoints and makes relevant calls to get the data.
In my case, I already have the data and I just need to pass the selected option to my Vue component which draws the graphs.
I also don't know any Vue either so... I think I need a little bit of help here.
Best way to help: Show me an example from this repository where dynamically selected option is passed to Vue. That's how I implemented all of this, by replicating, without knowing the details of these languages anyway :D
@lunny commented on GitHub (Jun 20, 2023):
If we want to introduce a frontend chart library but not two for this requirement and future requirements, I think we have some options below:
highcharts https://highcharts.com@sahinakkaya commented on GitHub (Jun 20, 2023):
In my previous comment, the graphs are already drawn with Chart.js but this is also a nice list @lunny. I examined them a little bit and I might consider switching to ApexCharts because they have exactly what we need: https://github.com/apexcharts/apexcharts.js#a-little-more-than-the-basic
I still need help with the issue I mentioned in my previous comment though. (Maybe @wxiaoguang could help me)
@fnetX commented on GitHub (Jun 20, 2023):
Thank you for the work on the charts. I suggest to keep the current information easily available, though. Like, make the contributors clickable easily, but also retain access to an overview of merged pull requests etc. I use this quite frequently to check what kind of activity a project has: Basic maintenance? New Features? Only users reporting bugs and no actual progress?
Another suggestion: Gitea already counts not only commits / code contributions in some places like the heatmap, and more and more people think this is the right direction for the software community, some even move over because of this. Maybe we can have an activity overview which does not only count code contributions, but also draw different kinds of contributions (in different colour), so you can check at a glance how the amount of commits, issues and pull requests change over time. Maybe even separated in opened / fixed ...
@silverwind commented on GitHub (Jun 20, 2023):
Can't really comment on chart libraries but as long as you're lazy-loading them with
await importonly on pages that use them, it should be fine.apexcharts does look pretty well-suited to the task yes.
@wxiaoguang commented on GitHub (Jun 21, 2023):
I am glad to help (if it is in my knowledge), but at the moment, I haven't got the point, the questions (experience with Go/Vue) seems general.
There are some Vue components, the data could be passed by either:
@sahinakkaya commented on GitHub (Jun 21, 2023):
@fnetX thanks for the suggestions. I created an endpoint which returns contributors' commits, additions and deletions for each week. I think this data can also be used to generate code frequency graph. I am not planning to implement it for this PR though as it is out of scope.
@silverwind, I don't do any
await importstuff but I think there is no performance issue because I am doing same thing as what Activity page does. A pull request is coming soon anyway :)And @wxiaoguang, is there a way to pass some property with pageData and not trigger a re-render of whole page? Fetching data is expensive so in Go file, I fetch all the data I need and pass it to Vue via pageData. When user change selection, I don't want to fetch data again.
Here, I have all the data for commits, additions and deletions (1 expensive call). If "commits" option is selected I draw graphs with commits data. When user change selected option to something else I just need to change the data I am feeding to graphs. Hope this makes sense and clears up the confusion.
@wxiaoguang commented on GitHub (Jun 22, 2023):
If you want to get some new data without re-rendering, then I think the only way is "fetch"
@silverwind commented on GitHub (Jun 22, 2023):
Definitely do it. If you don't code-split off the chart library with
await import, our JS payload for all pages will grow by its size, e.g. 200kb+. There are numerous examples in the codebase for such code-splits.@sahinakkaya commented on GitHub (Jun 22, 2023):
I opened a pull request: #27882. It would be nice if I can get some review and help from folks following this thread.
@silverwind I just saw your comment. OK, I will look into that 👍
@github-actions[bot] commented on GitHub (Feb 28, 2024):
Automatically locked because of our CONTRIBUTING guidelines