Calculate PublicOnly for org membership only once (#32234)

Refactoring of #32211

this move the PublicOnly() filter calcuation next to the DB querys and
let it be decided by the Doer

---
*Sponsored by Kithara Software GmbH*

(cherry picked from commit 43c252dfeaf9ab03c4db3e7ac5169bc0d69901ac)

Conflicts:
	models/organization/org_test.go
	models/organization/org_user_test.go
	routers/web/org/home.go

  rather simple conflict resolution but not trivial
  tests/integration/user_count_test.go had to be adapted (simple)
  because it does not exist in Gitea and uses the modified model
This commit is contained in:
6543 2024-11-11 01:38:30 +01:00 committed by Earl Warren
parent 45435a8789
commit 7751bb64cb
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
8 changed files with 76 additions and 56 deletions

View file

@ -75,8 +75,9 @@ func (countTest *userCountTest) Init(t *testing.T, doerID, userID int64) {
require.NoError(t, err)
countTest.memberCount, err = organization.CountOrgMembers(db.DefaultContext, &organization.FindOrgMembersOpts{
OrgID: org.ID,
PublicOnly: !isMember,
Doer: countTest.doer,
OrgID: org.ID,
IsDoerMember: isMember,
})
require.NoError(t, err)