-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Count only visible repos on profile #25928
Conversation
Instead of adding another template property, couldn't we just show the length of the to-be-rendered repos? As I understand, this goes to database twice, which is wasteful. |
This will not work. The repo count is always shown, no matter in which tab you are. But the list of repos is only loaded, when you are in the repos tab. |
Right, so only on the repo tab we could skip the count, hmm. |
We could run this code only, when the Repository tab is not selected, but I'm not sure, if it's worth the effort. |
How long does the extra code it take with a moderate amount of repos? That should give us an estimation whether it is worth it. |
I found out that the Bar rendered by a few more routes, so I decided to move the Code into a new function.
What exactly did you mean with "moderate amount of repos"? 50? 100? 500? Counting in SQL is relay fast, so I don't think it matters that much, even with more Repos. I also realized, that the same Problem apers in the Stars Tab. If you star an private Repo, you have for Visitors a higher Star Number than actually shown in the List. |
I know realized this is harder than I though: If you give someone access to a private Repo, the private Repo will be shown when the other Person visits your profile, so the Count would be wrong. I have to find an alternative. |
Yeah, likely not an issue. I recall at least in MySQL with InnoDB |
As I mentation, we have the Problem, that when a logged in User visits the Profile of another Use,w e need to check for each private Repo if the User has access, so a simple count is not enough. |
Indeed, this will need a complex query. |
Can we run this on every profile visit or does this take to long just for displaying a number? |
Depends on runtime. If it's sub-100ms for 1k repos, I'd say go for it. If slower, some cache may be beneficial, but it'll be hard to invalidate correctly. |
I changed the code now to use |
Seems good to merge. Not sure we should backport it though. |
This is a fix for a Bug hat was reported for 1.20 and doesn't introduce new Features, so I would say that it should be backported |
Head branch was pushed to by a user without write access
I was unable to create a backport for 1.20. @JakobDev, please send one manually. 🍵
|
|
A few pages don't load the repo count of an user/org, so it is not shown in the header. This happens mostly on org pages, but the package settings applies to the user page as well. Before: ![Screenshot 2023-08-31 at 12-45-36 Gitea Git with a cup of tea](https://github.com/go-gitea/gitea/assets/15185051/14a59998-2cf9-4771-82f4-5d1d6fcb31f4) After: ![grafik](https://github.com/go-gitea/gitea/assets/15185051/ff055aa0-7cde-49be-9522-437bf970be1d) Seen on go-gitea#26826 Regression of go-gitea#25928
A few pages don't load the repo count of an user/org, so it is not shown in the header. This happens mostly on org pages, but the package settings applies to the user page as well. Before: ![Screenshot 2023-08-31 at 12-45-36 Gitea Git with a cup of tea](https://github.com/go-gitea/gitea/assets/15185051/14a59998-2cf9-4771-82f4-5d1d6fcb31f4) After: ![grafik](https://github.com/go-gitea/gitea/assets/15185051/ff055aa0-7cde-49be-9522-437bf970be1d) Seen on #26826 Regression of #25928
Fixes #25914
This should probably be backported