Skip to content
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

Merged
merged 8 commits into from
Aug 11, 2023
Merged

Conversation

JakobDev
Copy link
Contributor

Fixes #25914

This should probably be backported

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jul 17, 2023
@pull-request-size pull-request-size bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jul 17, 2023
@silverwind
Copy link
Member

silverwind commented Jul 17, 2023

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.

@JakobDev
Copy link
Contributor Author

Instead of adding another template property, couldn't we just show the length of the to-be-rendered repos?

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.

@silverwind
Copy link
Member

Right, so only on the repo tab we could skip the count, hmm.

@delvh delvh added backport/v1.20 This PR should be backported to Gitea 1.20 type/bug labels Jul 17, 2023
@JakobDev
Copy link
Contributor Author

We could run this code only, when the Repository tab is not selected, but I'm not sure, if it's worth the effort.

@silverwind
Copy link
Member

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.

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Jul 21, 2023
@JakobDev
Copy link
Contributor Author

JakobDev commented Jul 21, 2023

I found out that the Bar rendered by a few more routes, so I decided to move the Code into a new function.

How long does the extra code it take with a moderate amount of repos?

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.

@JakobDev
Copy link
Contributor Author

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.

@silverwind
Copy link
Member

silverwind commented Jul 21, 2023

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.

Yeah, likely not an issue. I recall at least in MySQL with InnoDB COUNT() is O(n) but given that repo numbers are at most in the thousands, it won't be an issue.

@JakobDev
Copy link
Contributor Author

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.

@silverwind
Copy link
Member

Indeed, this will need a complex query.

@JakobDev
Copy link
Contributor Author

Can we run this on every profile visit or does this take to long just for displaying a number?

@silverwind
Copy link
Member

silverwind commented Jul 25, 2023

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.

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Jul 27, 2023
@JakobDev
Copy link
Contributor Author

I changed the code now to use repo_model.SearchRepository

@silverwind
Copy link
Member

Seems good to merge. Not sure we should backport it though.

@JakobDev
Copy link
Contributor Author

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

@silverwind silverwind added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Jul 31, 2023
@GiteaBot GiteaBot added lgtm/blocked A maintainer has reservations with the PR and thus it cannot be merged and removed lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. labels Jul 31, 2023
@silverwind silverwind removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Jul 31, 2023
auto-merge was automatically disabled August 10, 2023 16:15

Head branch was pushed to by a user without write access

@pull-request-size pull-request-size bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Aug 10, 2023
@lunny lunny dismissed their stale review August 11, 2023 05:13

The block problem has been resolved.

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/blocked A maintainer has reservations with the PR and thus it cannot be merged labels Aug 11, 2023
@lunny lunny added this to the 1.21.0 milestone Aug 11, 2023
@silverwind silverwind requested a review from lunny August 11, 2023 13:39
@lunny lunny added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Aug 11, 2023
@techknowlogick techknowlogick merged commit f3fbb7c into go-gitea:main Aug 11, 2023
@GiteaBot
Copy link
Collaborator

I was unable to create a backport for 1.20. @JakobDev, please send one manually. 🍵

go run ./contrib/backport 25928
...  // fix git conflicts if any
go run ./contrib/backport --continue

@GiteaBot GiteaBot added backport/manual No power to the bots! Create your backport yourself! and removed reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. labels Aug 11, 2023
@JakobDev
Copy link
Contributor Author

$ go run ./contrib/backport 25928
Unable to read `docs/config.yaml`: open docs/config.yaml: no such file or directory
* Backporting 25928 to origin/release/v1.18 as backport-25928-v1.18
* `git fetch origin main`

* `git fetch origin release/v1.18`

Unable to backport: unable to fetch release/v1.18 from origin: exit status 128
$ 

KazzmanK pushed a commit to KazzmanK/gitea that referenced this pull request Sep 6, 2023
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
lunny pushed a commit that referenced this pull request Sep 6, 2023
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
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Nov 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport/manual No power to the bots! Create your backport yourself! backport/v1.20 This PR should be backported to Gitea 1.20 lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Number of repositories includes the number of private repositories in profile page
7 participants