aboutsummaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2023-09-11 18:14:01 +0800
committerGitHub <noreply@github.com>2023-09-11 10:14:01 +0000
commitebff0513dbe8abd2c9807789c006f41d002416b5 (patch)
treefd7364ec34133204243ca5314825ab1f4353e7ef /routers
parent598465eb43e2c85f9e50934cc9b6b742a99e7d46 (diff)
downloadgitea-ebff0513dbe8abd2c9807789c006f41d002416b5.tar.gz
gitea-ebff0513dbe8abd2c9807789c006f41d002416b5.zip
Fix context cache bug & enable context cache for dashabord commits' authors (#26991)
Unfortunately, when a system setting hasn't been stored in the database, it cannot be cached. Meanwhile, this PR also uses context cache for push email avatar display which should avoid to read user table via email address again and again. According to my local test, this should reduce dashboard elapsed time from 150ms -> 80ms .
Diffstat (limited to 'routers')
-rw-r--r--routers/web/admin/users.go7
-rw-r--r--routers/web/user/setting/profile.go8
2 files changed, 11 insertions, 4 deletions
diff --git a/routers/web/admin/users.go b/routers/web/admin/users.go
index c83d652c3d..47dff6e852 100644
--- a/routers/web/admin/users.go
+++ b/routers/web/admin/users.go
@@ -314,7 +314,9 @@ func EditUser(ctx *context.Context) {
ctx.Data["DisableRegularOrgCreation"] = setting.Admin.DisableRegularOrgCreation
ctx.Data["DisableMigrations"] = setting.Repository.DisableMigrations
ctx.Data["AllowedUserVisibilityModes"] = setting.Service.AllowedUserVisibilityModesSlice.ToVisibleTypeSlice()
- ctx.Data["DisableGravatar"] = system_model.GetSettingWithCacheBool(ctx, system_model.KeyPictureDisableGravatar)
+ ctx.Data["DisableGravatar"] = system_model.GetSettingWithCacheBool(ctx, system_model.KeyPictureDisableGravatar,
+ setting.GetDefaultDisableGravatar(),
+ )
prepareUserInfo(ctx)
if ctx.Written() {
@@ -331,7 +333,8 @@ func EditUserPost(ctx *context.Context) {
ctx.Data["PageIsAdminUsers"] = true
ctx.Data["DisableMigrations"] = setting.Repository.DisableMigrations
ctx.Data["AllowedUserVisibilityModes"] = setting.Service.AllowedUserVisibilityModesSlice.ToVisibleTypeSlice()
- ctx.Data["DisableGravatar"] = system_model.GetSettingWithCacheBool(ctx, system_model.KeyPictureDisableGravatar)
+ ctx.Data["DisableGravatar"] = system_model.GetSettingWithCacheBool(ctx, system_model.KeyPictureDisableGravatar,
+ setting.GetDefaultDisableGravatar())
u := prepareUserInfo(ctx)
if ctx.Written() {
diff --git a/routers/web/user/setting/profile.go b/routers/web/user/setting/profile.go
index e1dc5680ca..0321a5759b 100644
--- a/routers/web/user/setting/profile.go
+++ b/routers/web/user/setting/profile.go
@@ -44,7 +44,9 @@ func Profile(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("settings.profile")
ctx.Data["PageIsSettingsProfile"] = true
ctx.Data["AllowedUserVisibilityModes"] = setting.Service.AllowedUserVisibilityModesSlice.ToVisibleTypeSlice()
- ctx.Data["DisableGravatar"] = system_model.GetSettingWithCacheBool(ctx, system_model.KeyPictureDisableGravatar)
+ ctx.Data["DisableGravatar"] = system_model.GetSettingWithCacheBool(ctx, system_model.KeyPictureDisableGravatar,
+ setting.GetDefaultDisableGravatar(),
+ )
ctx.HTML(http.StatusOK, tplSettingsProfile)
}
@@ -86,7 +88,9 @@ func ProfilePost(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("settings")
ctx.Data["PageIsSettingsProfile"] = true
ctx.Data["AllowedUserVisibilityModes"] = setting.Service.AllowedUserVisibilityModesSlice.ToVisibleTypeSlice()
- ctx.Data["DisableGravatar"] = system_model.GetSettingWithCacheBool(ctx, system_model.KeyPictureDisableGravatar)
+ ctx.Data["DisableGravatar"] = system_model.GetSettingWithCacheBool(ctx, system_model.KeyPictureDisableGravatar,
+ setting.GetDefaultDisableGravatar(),
+ )
if ctx.HasError() {
ctx.HTML(http.StatusOK, tplSettingsProfile)