aboutsummaryrefslogtreecommitdiffstats
path: root/routers/web/user/setting/profile.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2023-11-24 11:49:41 +0800
committerGitHub <noreply@github.com>2023-11-24 03:49:41 +0000
commitdf1e7d0067bb39913eb681ccc920649884fb1938 (patch)
tree2419feab5c28658adb7f71878df646bdc9bdc50e /routers/web/user/setting/profile.go
parentd24a8223ce1e47a0c9b103aae07f67c3112ca048 (diff)
downloadgitea-df1e7d0067bb39913eb681ccc920649884fb1938.tar.gz
gitea-df1e7d0067bb39913eb681ccc920649884fb1938.zip
Use db.Find instead of writing methods for every object (#28084)
For those simple objects, it's unnecessary to write the find and count methods again and again.
Diffstat (limited to 'routers/web/user/setting/profile.go')
-rw-r--r--routers/web/user/setting/profile.go8
1 files changed, 2 insertions, 6 deletions
diff --git a/routers/web/user/setting/profile.go b/routers/web/user/setting/profile.go
index 2390b0746c..d8331fef43 100644
--- a/routers/web/user/setting/profile.go
+++ b/routers/web/user/setting/profile.go
@@ -214,16 +214,12 @@ func Organization(ctx *context.Context) {
opts.Page = 1
}
- orgs, err := organization.FindOrgs(ctx, opts)
+ orgs, total, err := db.FindAndCount[organization.Organization](ctx, opts)
if err != nil {
ctx.ServerError("FindOrgs", err)
return
}
- total, err := organization.CountOrgs(ctx, opts)
- if err != nil {
- ctx.ServerError("CountOrgs", err)
- return
- }
+
ctx.Data["Orgs"] = orgs
pager := context.NewPagination(int(total), opts.PageSize, opts.Page, 5)
pager.SetDefaultParams(ctx)