From f3fbb7c67d21c01a58653c7ef9ae0e80dbb4becd Mon Sep 17 00:00:00 2001 From: JakobDev Date: Fri, 11 Aug 2023 19:08:05 +0200 Subject: Count only visible repos on profile (#25928) Fixes #25914 --- routers/web/shared/user/header.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'routers/web/shared/user/header.go') diff --git a/routers/web/shared/user/header.go b/routers/web/shared/user/header.go index 0ef93815a3..9b1918ed16 100644 --- a/routers/web/shared/user/header.go +++ b/routers/web/shared/user/header.go @@ -14,6 +14,7 @@ import ( "code.gitea.io/gitea/modules/markup" "code.gitea.io/gitea/modules/markup/markdown" "code.gitea.io/gitea/modules/setting" + "code.gitea.io/gitea/modules/util" ) // prepareContextForCommonProfile store some common data into context data for user's profile related pages (including the nav menu) @@ -110,3 +111,21 @@ func RenderUserHeader(ctx *context.Context) { defer profileClose() ctx.Data["HasProfileReadme"] = profileReadmeBlob != nil } + +func LoadHeaderCount(ctx *context.Context) error { + prepareContextForCommonProfile(ctx) + + repoCount, err := repo_model.CountRepository(ctx, &repo_model.SearchRepoOptions{ + Actor: ctx.Doer, + OwnerID: ctx.ContextUser.ID, + Private: ctx.IsSigned, + Collaborate: util.OptionalBoolFalse, + IncludeDescription: setting.UI.SearchRepoDescription, + }) + if err != nil { + return err + } + ctx.Data["RepoCount"] = repoCount + + return nil +} -- cgit v1.2.3